Question: Write a C++ function using the following specification Function Name: printDigit() Arguments: One integer input parameter The valid inputs are numbers from 0 to 100.

Write a C++ function using the following specification

Function Name: printDigit()

Arguments: One integer input parameter

The valid inputs are numbers from 0 to 100.

The function should display output for each number using the word associated with the digit.

For the numbers 20-99 the function MUST use an algorithm to determine the tens word to display and the ones word to display. It must not use a decision or selection statement that matches each number in the range between 20-99.

The function should return an integer value as follows:

0 if the function return is success

-1 if the function encountered an error (incorrect input for example).

The program you submit should include the code for the function described above along with code in main to test the function. Test your program using values from -1 to 101. Use a for loop to call the function with each of the values.

-1 and 101 should result in the function returning an error and the function should not print anything in those cases. Your test code should display the return value from the function each time it is called.

The program should be well commented and contain all of the test cases in the main function.

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!