I am getting stuck on this hw problem/function because I need to do it recursively:
baseConversion: takes three integer parameters and returns a string representing the answer of the base conversion. For example when baseConversion (6,10,2) is called, it will take 6 in base 10, convert it to base 2 and return the string “110”
I am pretty sure I would have to convert the number into base 10 first and I think before I can do any of that, I need to turn my first number passed into a string because I need to multiply each 10s digit by a power of 10 and then add the results together. How might I go about doing this?
All I have right now is the basic skeletal structure of the function:
I am not sure how I can access the different tens places.. For instance, lets say I have a number in base 3 I was to convert but the number is 2222. My number converted to base 10 is 2*3^3 + 2*3^2 + 2*3^1 + 2*3^0Code:char** baseConversion(int num, int base, int newBase){ }
But how can I get to each 10s spot individually to do that arithmetic in a recursive function?