2. Write a program that asks the user to enter a series of one-digit positive nu
ID: 1806132 • Letter: 2
Question
2. Write a program that asks the user to enter a series of one-digit positive numbers (you will need to do error checking). When they have finished (Note: the user should indicate that they are finished by entering the value 10), print out how many of each number the user entered. There must be two functions Here is a sample output if the user entered 0,7,7,2,7,10: Hint: Use an array to hold an accumulator (counter) for each digit. Note: Do not output a value of 0 for the number of digits entered. Enter a one-digit number or 10 to exit: 0 [enter] Enter a one-digit number or 10 to exit: 7 [enter] Enter a one-digit number or 10 to exit: 7 [enter] Enter a one-digit number or 10 to exit: 2 [enter] Enter a one-digit number or 10 to exit: 7 [enter] Enter a one-digit number or 10 to exit: 10 [enter] You entered 1, 0(s) You entered 1, 2(s) You entered 3, 7(s) Arrays of Reference Variables You can create arrays of any data type including references. For example, we can write: string numberWords[5] = {"Zero", "One", "Two", "Three", "Four"};Explanation / Answer
#include using namespace std; int main(){ int count[10]={0}; int input; do{ coutinput; if(inputRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.