C Program to convert binary to decimal number
In this example, we will learn how to convert the binary to decimal number in the c programming language. Following is the solution to the problem. code: #include <math.h> #include <stdio.h> int main() { long long num,original; printf("Enter a binary number: "); scanf("%lld", &num); original=num; int deci = 0, i = 0, remainder; while (num != 0) { remainder = num % 10; num /= 10; deci += remainder * pow(2, i); ++i; } printf("%lld in binary = %d in decimal", original, deci); return 0; } Output: Enter a binary number: 111 111 in binary = 7 in decimal