Home / Expert Answers / Computer Science / write-a-function-in-c-using-the-following-specification-1-nbsp-function-name-printdigit-2-a-pa752

(Solved): Write a function in C++ using the following specification 1-  Function Name: printDigit() 2-A ...



Write a function in C++ using the following specification

1-  Function Name: printDigit()

2-Arguments: One integer input parameter The valid inputs are numbers from 0 to 100 inclusive.

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

4- 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.

5- 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).

6- The program you submit should include the code for the function described above along with code in main to test the function.

7-Test your program using values from -1 to 101.

8-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.

9- 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. The program should use the cout object for output.



We have an Answer from Expert

View Expert Answer

Expert Answer


include using namespace std; int printDigit(int n){ string str[] = {"zero","one", "two", "three", "four", "five", "six", "seven", "eight",
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe