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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started