Programming in c++ Looping Dale/eems/Headington
1 Looping
Programming in C++ Chapter 6 Topics While Statement Syntax o Phases of Loop Execution Two Types of Loops: Count-Controlled Loops &Event-Controlled Loops s Using the End-of-File Condition to Control Input Data s Using a While Statement for Summing and ounting How to Design Loops %Nested While Loops s Loop Testing and debugging
2 Chapter 6 Topics ❖While Statement Syntax ❖Phases of Loop Execution ❖Two Types of Loops: Count-Controlled Loops &Event-Controlled Loops ❖Using the End-of-File Condition to Control Input Data ❖Using a While Statement for Summing and Counting ❖How to Design Loops ❖Nested While Loops ❖Loop Testing and Debugging
Programming in C++ What is a loop? %A loop is a repetition control structure it causes a single statement or block to be executed repeatedly
3 ❖A loop is a repetition control structure. ❖it causes a single statement or block to be executed repeatedly What is a loop?
Programming in C++ While Statement SYNTAX while( Expression ∥ oop body NOTE: Loop body can be a single statement, a null statement, or a block
4 While Statement SYNTAX while ( Expression ) { . . // loop body . } NOTE: Loop body can be a single statement, a null statement, or a block
Programming in C++ When the expression is tested and found to be false, the loop is exited and control passes to the statement which follows the loop body. WHILE LOOP FALSE Expression TRUE body statement
5 When the expression is tested and found to be false, the loop is exited and control passes to the statement which follows the loop body. WHILE LOOP FALSE TRUE body statement Expression