Write a program that asks the user to enter a series of one-digit positive numbe
ID: 3658618 • Letter: W
Question
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:
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)
Explanation / Answer
#include using namespace std; int main() { int store[10]; int value,i; for(i=0;i < 10;i++) { store[i]=0; } do { cout>value; if(value>=0 && value < =9) { store[value]=store[value]+1; } }while(value!=10); for(i=0;i < 10;i++) { if(store[i]>0) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.