Program to convert decimal to binary using while loop in C-language

#include<stdio.h>
int main()
{
    int a,b,f;
    printf("Enter the decimal number\n");
    scanf("%d",&a);
    printf("Binary of %d is\n",a);
    while(a>0)
    {
        b=a%2;
        a=a/2;
     
        f=f*10+b;
    }
    printf("%d",f);
}

OUTPUT
Enter the decimal number
15
Binary of 15 is
1111

Visit Homepage

Comments

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language