Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 !!!!!

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions