Convert the binary number to decimal number
/*WAP to convert
the binary number to decimal number*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int
bin,dec=0,d,t=0;
clrscr();
printf("enter
the binary number:");
scanf("%d",&bin);
while(bin!=0)
{
d=bin%10;
dec=dec+d*pow(2,t);
t++;
bin=bin/10;
}
printf("the
decimal number is %d",dec);
getch();
}
OUTPUT:
enter the binary
number:1111
the decimal
number is 15
No comments:
Post a Comment