Question: Help with C++ code run before submitting I will up vote !!!!! Write a Ct+ recursive function that periorms conversion from decimal to any number
Help with C++ code run before submitting I will up vote !!!!!
Write a Ct+ recursive function that periorms conversion from decimal to any number of base n, where n is in the range 2.10 or n=16 (hexadecimal. The algorithm for this conversion is to repeatedly divide the decimal number by n, until it is 0 . Each division produces a remainder, which becomes a digit in the comverted number. For example. if we want to convert the decimal 14 number to a number of base 3 , we would apply the following steps: 14/3=4 remainder 2 4/3=1 remainder 1 1/3=0 remainder 1 Thus, the result is (112)3. The only problem with this algorithm is that the first division generates the low-order digit, the next division generates the second order digit, and so on, until the last division produces the high order digit. Thus, if we output the digits as they are generated, they will be in reverse. order. Thus, you should use recursion to reverse the order of output. Implement a recursive C+ function that performs the conversion from decimal to amy number of base n that has the following header definitiont: string DectoBaseNoint num, int base: Where, num is the passed decirin buinber and base is the base of the number to be converted to in the range 210 or 16 . The function returns the converted number as a string of digits. In the case of base 16, the function returns the converted number as a string of digits and letters (A.F which represent the values 10-15, respectiveiy). For any other ilegal base n, the furiction displays the message "lavalid Base: n and refurns a nuli string
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
