Untitled
unknown
plain_text
a year ago
581 B
0
Indexable
Never
#include <stdio.h> #include <math.h> int binaryToDecimal(long long binaryNumber) { int decimalNumber = 0; int remainder, i = 0; while (binaryNumber != 0) { remainder = binaryNumber % 10; binaryNumber = binaryNumber / 10; decimalNumber += remainder * pow(2, i); i++; } return decimalNumber; } int main() { long long binaryNumber; printf("Enter a binary number: "); scanf("%lld", &binaryNumber); int decimalResult = binaryToDecimal(binaryNumber); printf("Decimal: %d\n", decimalResult); return 0; }