Question: Write a complete C++ program that do following. 1)Read a positive integer from the user with proper prompt. Assume that this user would not start

Write a complete C++ program that do following.

1)Read a positive integer from the user with proper prompt. Assume that this user would not start the integer with digit 0.

2)Create a size 10 array as counters for digits 0 - 9.

3)Use a while loop for processing:

a)Single out the current last digit using modular 10 technique

b)Increment the corresponding counter through the index derived in a).

4)At the end display the non-zero counters and its corresponding digit in ascending order, i.e. 0 to 9.

For example, if the user enter 1773233, the output should be:

All digits occurrences:

1: 1

2: 1

3: 3

7: 2

Note:

1.To accept longer input integer, long long data type can be used to replace int as a type modifier.

2.Using switch statement(s) or nested/concatenated if else statements to increment any digit's counter will result in a point deduction.

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!