Description
The purpose of this challenge is to use the FOR loop in various ways. This challenge also uses the concepts of accumulators and loops.
Requirements
- Ask the user to enter a string. Display this string 10 times, once each per line.
- Ask the user to enter two integers. The user should enter the first number as a smaller value than the second number. Then, write a FOR loop to display all the integer numbers between the first user number and the second user number. Declare an integer called total and initialize this to 0.
- In the same FOR loop, add up all the the numbers as the loop counts through the numbers. Use the total variable to accumulate the total as the loop runs (remember accumulators?)
- At the end, display the calculated total
- Ask the user to enter a single letter (between a and z). Then, display all the letters from a up to that letter; display these letters on one line. Then, on a subsequent line, display all the letters from the next letter all the way to z. See the Sample Interaction
- In this section, you want to display the word “Help!” However, first ask the user to enter a number. This number the user enters represents how many e’s are in the displayed word. For example, if the user types in 3, then you would display “Heeelp!” If the user types in a negative number or a number bigger than 20, then only display one e (as in Help!)
Sample Interaction / Output
Enter a word: coding coding coding coding coding coding coding coding coding coding coding Enter two numbers: 11 17 11 12 13 14 15 16 17 Total: 98 Enter a character: h abcdefgh ijklmnopqrstuvwxyz How many e's? 5 Heeeeelp!
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-LOOP00012
Print Requirements