C Language
C Programs
Binary To Decimal Conversion in C
/* Write a C program to convert the given binary number into its equivalent decimal */
#include
void main()
{
int num, bnum, dec = 0, base = 1, rem ;
printf(“Enter the binary number(1s and 0s)n”);
scanf(“%d”, &num); /*Enter maximum five digits or use long int*/
bnum = num;
while( num > 0)
{
rem = num % 10;
dec = dec + rem * base;
num = num / 10 ;
base = base * 2;
}
printf(“The Binary number is = %dn”, bnum);
printf(“Its decimal equivalent is =%dn”, dec);
} /* End of main() */
/*—————————————————
Outpput
Enter the binary number(1s and 0s)
1010
The Binary number is = 1010
Its decimal equivalent is =10
—————————————————-*/
More From sriramraj
sriramraj Recommends
- jobs in indian railways (StudentsTips)
- Free WordPress Themes in Internet (StudentsTips)
- Top Bschools in India (StudentsTips)
- Apple to tighten IAP rules to allow only one in app purchace (perivision)
- Tethering the iPhone to your laptop is suppose to be coming. (perivision)
- How to get a trademark registered in India (bizniche)
No related posts.

