Question: C++problem Write a program which asks the user to enter an integer. Your program should then display the sum of the even digits of the

C++problem

Write a program which asks the user to enter an integer. Your program should then display the sum of the even digits of the integer. A typical run would be:

Enter an integer greater than 10000: 34 34 is not greater than 10000 Enter an integer greater than 10000: 39428 The sum of the even digits of 39248 is: 14

Hints:

Use a loop to ensure that the number entered is > 10000.

You dont need to be concerned with the length of the integer, use a while loop which ends when the number is equal to zero.

You will need to preserve the original value entered, so after the user enters it, copy it to another int variable.

You can access the last digit of an integer by dividing modulo by 10, eg digit = workingNumber % 10;

You can remove the last digit of an integer by dividing by 10, eg workingNumber /= 10;

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!