lect07 For and Do-While Loops

lect07 For and Do-While Loops - Exam 1 Class Average Median...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Exam 1 Class Average Median 100s 10:00 83.47 92 2 11:25 87.51 93 3 6:25 92.22 95 4 ALL 88.18 93 9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The while Loop Syntax: while ( condition ) statement ; while ( condition ) { statement ;       statement ; }
Background image of page 2
The for Loop Syntax: for ( expression1 ; condition ; expression2 ) statement ; for ( expression1 ; condition ; expression2 ) { statement ;    statement ; } Same as: expression1 ; while ( condition ) { statement ; expression2 ; }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example for Loop int numEmployees,curNum; cout << “Enter Number of Employees: “; cin >> numEmployees; if (numEmployees > 0) { for (curNum = 0; curNum < numEmployees;curNum++) { cout << “Welcome to CorpLand!” << endl; } }
Background image of page 4
Looping for Input char letterEntered = ‘A’; while (letterEntered != ‘Z’) { cout << “Enter a letter: “; cin >> letterEntered; }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Looping until Flag boolean noMoreData(); boolean done = false; while (!done) { // do a bunch of stuff if (noMoreData() == true) done = true; } cout << “We’re all through – thank you!”
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 03/03/2010.

Page1 / 12

lect07 For and Do-While Loops - Exam 1 Class Average Median...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online