BINARY TO DECIMAL

#include<stdio.h>
int convert(int n);
void main()
{
int dec,bin;
printf("enter the binary number:\n");
scanf("%d",&bin);
dec=convert(bin);
printf("the decimal equivalent of %d is %d\n",bin,dec);
}
int convert(int bin)
{
if(bin==0)
{
}
else
{
}
}
return 0;
return(bin % 10+2*convert(bin/10));

Output

Enter a binary number:1010
1010 in binary = 10 in decimal

Posted on by