C program to convert binary to decimal


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int bin,dec=0,i=0,j=0;
printf("\n ENTER THE BINARY NUMBER :  ");
scanf("%d",&bin);
while(bin>0)
{
i=bin%10;
dec=dec+pow(2,j)*i;
j++;
bin=bin/10;
}
printf("\n DECIMAL EQUIVALENT = %d ",dec);
getch();
}

For more C programs - click here

Popular posts from this blog

8051 Assembly Program Code for Sorting in Descending Order - Keil - AT89C51

8051 Assembly Program Code for Sorting in Ascending Order - Keil -AT89C51