2.4 Guided PracticeUsing a For() Loop for Repetition
Iteration structures, such as for() loops, continuously repeat commands as long as a condition is true. All loops contain three syntax items, a starting point, an ending point, and either an incrementer or decrementer operator to step through each repetition. You also have to declare a variable to control the counter. If the counter is not changed inside of the loop using an incrementer or decrementer operator, then the loop will never end resulting in an infinite loop.
For() statements are also known as determinant loops. This means that we know where we want the loop to start and where we want it to end.
The following program uses a for loop to find factors of a user-entered number. For this determinant loop, we want to start the count at 1 and end at the number the user entered. Every time the condition is true, The user-entered number will be divided by the value of the count at the particular time using the modulus operator. If there is no remainder (==0) then the value stored in the variable count will be displayed. If there is a remainder, or if the condition is false, nothing will be displayed.
Instructions
Follow these instructions to complete your assignment:
1. Use Flowgorithm to create the flowchart in the tab below.
2. Select the Code tab and enter the code into your compiler.
3. Compile your code and run. Your output should match the image on the Output tab.
4. Paste your flowchart and a screenshot of your output (including the Title Bar showing the path and name of your code) into a Word document (.docx).
5. Submit the “.c” code file, which should include a comment line with your name and the date.
6. Submit the Flowgorithm (.fprg) file.
7. Save your files and upload them using the instructions below.
· Code
· Output
New Flowchart Shape: We use the hexagon shape to show looping structures.