Programming

profileAdejoke
CIS1262.6GuidedPractice.docx

2.6 Guided PracticeUsing a Do...While() Loop for Repetition

The last iteration statement we will be learning this week is known as the do..while() loop.  Unlike the while() loop this loop is different to where the condition is tested at the end, rather than the beginning.  So, the loop always runs at least once.

The program below uses a do..while() statement to display a message.  It also is using a sentinel value to allow the user to decide when they wish to end the loop.  You will notice that the user is being prompted to enter the letter Y to continue and N to exit the loop.  Keep in mind that when using letters in programming case-sensitivity matters.

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.

 

· Flowchart

· Code

· Output

New Flowchart Shape - Notice that the hexagon shape for the do...while loop is located below the executable statements.  This means that those statements will always run first before the condition is checked.  The OR operator looks at both conditions if one of them is true the entire condition is true.

Diagram  Description automatically generated

Graphical user interface, text, application  Description automatically generated

Text  Description automatically generated

image3.png

image1.png

image2.png