Skip to main content

While Loop In C++


A while loop repeat to execute target statement as long as the given condition is true.

Syntax:
      Initialization ;
      While(Final condition){
     Increment/decrements}

Initialization: Read the previous lecture.
Final condition: Briefly explained in previous lecture.
Increment/decrements: Learn more read the previous lecture.





Initialization: in this part of the for loop can declared the starting point of for loop. That’s means initial point of statement execution .in the program the red block are indicate initialization.

Final condition: the end point of program. The ending period  statement execution , that defined by the final condition. In the program the green block are indicate the final condition.

Increment/decrements: The increment operators are use to increases the values of its operand and decrements operators are use to increases the values of its operand. in the program yellow box are indicate increment.

 Click for see flow chart on  while loop


Comments

Popular posts from this blog

Switch, Case, Default Statements In C++

Switch case is uses as alternative of if….else. When we need to use long term of if…else then we use switch case for reducing program execution time. syntax: Switch(variable){ Case value 1: Statement; Break; Case value 2: Statement; Break;

do...while loop in C++

The do while loop is very similar to while loop . In the while loop first check final condition then execute the statement. But in the do while loop first execute the statement then check the final condition. Syntax: Initialization; Do{ increment/decrement;   } while(Final condition)

For Loop In C++

A loop can repeat the statement of a particular job continuously for a specific number of times. Loop Description Syntax For The condition can tested before statement execution.   For(Initialization, Final condition, increment /decrements ) { statement; } while First it check the condition then do the job. Initialization; While(Final condition) { Statement; increment /decrements; } Do..while First do job then test the condition. Initialization; Do{ Statement; increment /decrements; } While(Final condition)