Question: C++ ONLY 1. (Sum the digits in an integer) Write a program that reads an integer and adds all the digits in the integer. For

C++ ONLY

1. (Sum the digits in an integer) Write a program that reads an integer and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14. Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit. For instance, 932 % 10 = 2 and 932 / 10 = 93. Here is a sample run:

Enter an integer: 999

The sum of the digits is 27

2. (Game: Prediction) Write a program that generates a random two-digit integer. The program prompts the user to predict the generated number by entering a two-digit integer, and then determines the accuracy of the users prediction according to the following rules:

If the users prediction matches the generated number exactly, the accuracy is 100%.

If one digit in the users predicted number matches a digit in the generated number, the accuracy is 50%.

If none of the digits in users predicted number matches with the generated number, the accuracy is 0%.

3. (Geometry: points in triangle?) Suppose a right triangle is placed in a plane as shown below. The right-angle point is placed at (0, 0), and the other two points are placed at (200, 0), and (0, 100). Write a program that prompts the user to enter a point with x - and y -coordinates and determines whether the point is inside thetriangle.

C++ ONLY 1. (Sum the digits in an integer) Write a program Here are some sample runs: Enter a point's x- and y-coordinates: 100.5 25.5

The point is in the triangle

Enter a point's x- and y-coordinates: 100.5 50.5

The point is not in the triangle

4. (Display the Sundays in a month) Write a program that prompts the user to enter the month and first day of the month, and displays all the Sundays in that month. For example, if the user entered the month 9 for September, and the first day 4 for Wednesday, your program should display the following output:

This is the month of September

The first day of this month is Wednesday, September 1st!

There are 4 Sunday(s) in this month:

Sunday, September 3rd

Sunday, September 10th

Sunday, September 17th

Sunday, September 24th

5. (Display pyramid) Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid, as shown in the following sample run:

Enter the number of lines: 7

that reads an integer and adds all the digits in the integer.

opl (0, 0) (200, 0)

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!