# CPT121 Task 2.1.3. Practice Exercises -Repetition Solved

30.00 \$ 15.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` zip` solution files instantly, after Payment

## Description

5/5 - (1 vote)

Task 2.1.3 Practice Exercises – Repetition

1. Write for loops / nested for loops to print the following.
1. 1 2 4 5 7 8 10 11 … 98 100

(numbers from 1 to 100 which are not a multiple of 3)

1. 1 2 3 … 9 10 2 4 6 … 18 20 3 6 9 … 27 30

10 20 30 … 90 100

1. 54321

5432

543

54

5

1. *

**

***

****

*****

1. Write a program which repeatedly prompts the user to enter final course results (integer values in the range 0 – 100), until the user enters a value of -1 to signal the end of their input sequence.

Once the user has finished entering input the program should display the lowest and highest results, as well as the average result across the set of results that were entered.

Note that you should not need to use an array or any other storage structure to store individual course results entered by the user, but you will need to consider which form of loop is best suited to this task and where the calculation or determination of the figures noted above will need to be done.

1. Write a program which prompts the user to enter a name and then, using a suitable repetition structure, gives a (second) user up to five (5) attempts to guess the name that was entered previously.

For each guess the program should display the number of letters that are correct in the guess (eg. if the name is Johnathan and the user enters “Johnny” then the program should display that 4 out of 9 letters were guessed correctly).

If the user guesses the name correctly on or before the fifth attempt then they win the game, otherwise they have lost the game.  The program should display a suitable message in both scenarios (ie. win or lose) once the game has finished.