Question: For this homework you are to write a C++ program with 2 functions: unsigned numberFromDigits(string digits, unsigned base); This function may awc (assume without checking)

For this homework you are to write a C++ program with 2 functions:

unsigned numberFromDigits(string digits, unsigned base);

This function may awc (assume without checking) that base is in [2, 16], that every char in digits iw

a valid digit in the given base (e.g. one of 0123456789ABC in base 13), and that the number being

represented is small enough to fit in an unsigned.

numberFromDigits does no i/o (input/output). Its job is to return the number that the digits

represent in the given base.

For example, numberFromDigits("413", 5) should return the number 108.

string digitsFromNumber(unsigned number, unsigned base);

This function may awc that base is in [2, 16].

digitsFromNumber does no i/o (input/output). Its job is to create and return a string that shows

the digits used to represent the number in the given base.

For example, digitsFromNumber(108, 5) should return the string "413".

Write a main that calls both these functions. You decide the details of your main.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!