C program to convert binary number to decimal number.
In this program, I have discussed about the C program to convert binary number to decimal number
#include<stdio.h>
int main()
{
int num,binary,decimal=0,base=1,rem;
printf("Enter a binary number:");
scanf("%d",&num);
binary=num;
while(num>0)
{
rem=num%10;
decimal=decimal+rem*base;
num=num/10;
base=base*2;
}
printf("The binary number is %d\n",binary);
printf("The decimal number is %d\n",decimal);
}
Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.
Enjoy programming in C.
0 comments:
Post a Comment