C Program To Convert Binary Number Into Decimal Number
Example
#include<stdio.h> #include<math.h> void main() { long int i, number, decimal = 0, h; printf("n Enter Binary Number: "); scanf("%ld", &number); printf("n The decimal conversion of %ld is: ", number); for (i = 0; number != 0; ++i) { h = number % 10; decimal = (h) * (pow(2, i)) + decimal; number = number / 10; } printf("%ld", decimal); }
Output:
Enter Binary Number: 1011001 The decimal conversion of 1011001 is: 89