Skip to main content

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)

For loop

A loop can control data execution by using its three parts


    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.

3Increment /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.


Flow chart on for 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)

Input & Output In C++ (Basic)

Cout<<”Print sentence”;     This statement is use to print out any kinds of sentence or string type values. Cout<<345;     This statement is use to print out any kinds of numeric numbers, without change. Cout<<variable;        This statement is use to print the value of variable. The value of the which variable we want to print, It is need to write that variable on variable place.