Working of For LOOP in C++
Working of For LOOP in C++
Pattern:
for(int x=n;x<=n1;x++){ // n and n1 means any numbers
}
Initialization Part: Declare variable and assign it any value
i.e 0,1,2 etc.
Step 1: First of all initialization part will be checked and assigned value
of declared variable will be stored.
[Note that increment will occur after working of loop for the
checked condition and not just after checking the condition]
Step 4: Now the same procedure will be repeated for the changed
value until the condition gets false and loop gets terminated.
Example:
Input Code: Output:
#include<iostream> *****
Remarks:
Increment in first loop will occur when endl command will be
performed after termination of first loop.
When second loop will be terminated then value of j stored in
memory will also be removed from memory.