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

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

OUTPUT
Enter the binary number
1011
Decimal of 1011 is
11

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