Saturday, January 4, 2014

Object oriented Programming



Note Download

Note |Answer Test 1 | Example Inherit | Answer Quiz 1(Reff)
|Pass year|






While loop


A while loop statement repeatedly executes a target statement as long as a given condition is true.
Syntax:


The syntax of a while loop in C++ is:while(condition) { statement(s); }



Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any non-zero value. The loop iterates while the condition is true.


When the condition becomes false, program control passes to the line immediately following the loop.


Flow Diagram:



















Here, key point of the while loop is that the loop might not ever run. When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.





















source: http://www.tutorialspoint.com/cplusplus/cpp_do_while_loop.htm


******************************************************************************


Do while loop




A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.
Syntax:


The syntax of a do...while loop in C++ is:do { statement(s); }while( condition );



Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop execute once before the condition is tested.


If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop execute again. This process repeats until the given condition becomes false.
Flow Diagram:





source:http://www.tutorialspoint.com/cplusplus/cpp_do_while_loop.htm

No comments: