2 Answers
#include <stdio.h>
int binarytodecimal(int binarynum)
{
if (!(binarynum / 10))
return binarynum;
return (binarynum % 10 + binarytodecimal(binarynum / 10) * 2);
}
int main()
{
int binarynum;
printf(“enter the binary number \n”);
scanf(“%d”, &binarynum);
printf(“equivalant decimal number is %d”, binarytodecimal(binarynum));
return 0;
}