Question: 6. Name your file ws8.cpp. Write a program that prompts the user to input an integer and then outputs both the individual digits of the

 6. Name your file ws8.cpp. Write a program that prompts the

6. Name your file ws8.cpp. Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. For example, it should output the individual digits of 3456 as 3 4 5 6, and the sum as 18, output the individual digits of 2345526 as 2 3 4 5 5 2 6, and the sum as 27, output the individual digits of 4000 as 4 0 0 0 and the sum as 4. Hint: First find the number of digits. Then divide by the number of digits and use the % operator for the remainder of the division operation to break down the number into individual digits. You will need to use while loops for both of these steps. If you use the pow function, remember it returns a double. You will need to static_cast it to an int. This is all about integers and we don't want floats or doubles

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!