diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c index 2c09276..0b1bc48 100644 --- a/src/main/c/BasicMode.c +++ b/src/main/c/BasicMode.c @@ -19,3 +19,16 @@ long long int DecToBin(long long int n) { return bin; } +// convert binary to decimal +long long int BinToDec(long long int n) { + long long int dec = 0, i = 0, rem; + + while (n != 0) { + rem = n % 10; + dec += rem * pow(2, i); + i++; + n /= 10; + } + + return dec; +}