07-Loops.pptx - ICS 212 Program Structure William McDaniel Albritton M.S Memory Allocation Loops while Loops for Loops do Loops break Statement continue

07-Loops.pptx - ICS 212 Program Structure William McDaniel...

This preview shows page 1 - 13 out of 51 pages.

ICS 212 Program Structure William McDaniel Albritton M.S.
Image of page 1
Memory Allocation Loops while Loops for Loops do Loops break Statement continue Statement Input/Output Redirection
Image of page 2
Image of page 3
Loops
Image of page 4
Loops Loops are used to repeat the execution of selected code
Image of page 5
Counting Loop Loops that use counters to control the number of repetitions The counter value is increased or decreased each time the loop body is executed The loop terminates when the counter reaches a certain value Example: print “hello world” ten times
Image of page 6
Sentinel Loop Loops that use special values called sentinels to terminate the loop The body of the loop is executed until the sentinel is found For example, a program that continues calculating the interest rate and stops after the last customer We can choose the sentinel to be the characters ‘n’ or ‘N’
Image of page 7
Pre Test and Post Test Loops When is the condition tested? false true condi tion stateme nt(s) to be repeated false true condi tion stateme nt(s) to be repeated
Image of page 8
C Loops C features three different kinds of loops while loop for loop do loop
Image of page 9
Image of page 10
while Loop
Image of page 11
while Loop May be a sentinel or counting loop Pre-test loop The flowchart representation looks like this: false true condi tion initializ ation loop body update
Image of page 12
Image of page 13

You've reached the end of your free preview.

Want to read all 51 pages?

  • Spring '18
  • Control flow, Loop execution, Sentinel Loop,  Condition,  Sentinel

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes