Is there a way to enter a binary number and print its decimal equivalent.
Is there a way to enter a binary number and print its decimal equivalent.
If you mean is there a way in the C standard library, no. But it wouldn't be a chore to write one.
Code:#include <stdio.h> #include <stdlib.h> int main(void) { char buff[16]; int number; fgets(buff,16,stdin); number = strtol(buff,0,2); printf("Decimal value is %d\n",number); }