Question: Hi I need help with this code as I'm not sure how to really alter it to fix it how my professor wants it basically
Hi I need help with this code as I'm not sure how to really alter it to fix it how my professor wants it basically what the code is intaking a string param and only a string param, and
create a recursive function to convert any string binary given and give the correct decimal value.
int binToDec( string bin,int i=0 ) {
// If we reached last character
int n = bin.length();
if (i == n-1)
return bin[i] - '0';
return ((bin[i] - '0') << (n-i-1)) + binToDec(bin,i+1);
}
however how do i implement this to not use the int i parameter with the recursion.
this is what I have
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
