Convert to Decimal Wrtie a function that gets a number (containing only 1’s and 0’s) and returns its decimal representation. You can assume validity of the input. For example: INPUT : 101 OUTPUT : 5 int toDecimal(int num) Answer int toDecimal(int num) { int digit; int toDecimal = 0; int base = 1; while (num > 0) { digit = num % 10; toDecimal = toDecimal + base * digit; base *= 2; num = num / 10; } return toDecimal; } INPUT : 1001 OUTPUT : 9 INPUT : 1111 OUTPUT : 5 INPUT : 1100 OUTPUT : 12 Next Question>>>