Friday, January 02, 2009

Program to convert binary number to Decimal number

Buzz It
/*Program to convert binary number to Decimal number */

//

#include
#include
#include
void main()
{
int dec=0,i=0,d;
long bin;
clrscr();
printf("Enter the number \n");
scanf("%ld",&bin);
for(i=0;bin>0;i++)
{
d=bin%10;
dec=dec+(d*pow(2,i));
bin=bin/10;
}
printf("The decimal =\t%d",dec);
getch();
}

-->

0 comments:

Post a Comment