Friday, May 25, 2012

C Program That Convert The Binary Number To Decimal Number




Hello guys,today i'm sharing a program that convert any binary number to decimal number.Just go through this code and try to understand it,i'm sure that you will not face any problem while reading it.




#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int number,sum=0,rem,x,n;
clrscr();
printf("\n\n\n Enter any binary number:");
scanf("%d",&n);
number=n;
x=0;
while(number!=0)
{
rem=number%10;
sum=sum+(rem*pow(2,x));
x++;
number=number/10;
}
printf("\n\n\ndecimal number of binary num %d is %d",n,sum);
getch();
}






********Thanks Friends********

No comments:

Post a Comment

Please Give Me Your Views

Popular Posts