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 cheque enter number is even or odd in c-language

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

Creative Pattern of Rhino in C-language

Variable & Datatype for C-programming

Division of two numbers in C-language