@ -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;