C Program to Convert Binary Number into Decimal Number
This C Program Converts binary number into decimal number,the base is initialized as 1 and keeps on multipied by a factor of 2.
#include<stdio.h>
main()
{
int num;
int bnum;
int dec=0,base=1,rem;
printf("Enter a Binary Number n");
scanf("%d",&num);
bnum=num;
while (num>0)
{
rem=num%10;
dec=dec+rem*base;
num=num/10;
base=base*2;
}
printf("Decimal Number is %d",dec);
}
OUTPUT:
Enter a Binary Number
110
Decimal Number is 6
Recent Comments