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

Introduction of C-language.

Syntax of C-language

Variable & Datatype for C-programming

Errors in C-language

Program to see all ASCII value using for loop in C-language

Language Translator of C-language

Program to find the sum of two array into the third in C-language

Program to cheque enter number is even or odd in c-language

Linear search in C-language