LOOPS:
loop s an instructions/ gp of inst that comp execute repeatedly to a specified num of time
FOR:
for(expr1; expr2; expr3;)
for (initialize; condition; expression)
all expr r optional but for must have the semicolon;
WHILE
Initialization;
while (condition)
{one or more c++ statements}
DO WHILE
Initialization;
do {one or more C++ stat}while (condition);
DIFFERENCE B/W FOR & WHILE
Æ when we already know the number of execution then we use for loop other wise while.
Æ for loops r known as determined loops e,g display shahid 5times.
Æ while loops are known as undetermined loop e,g compute the sum of numbers until we get 99.
DIFFERENCE B/W DO WHILE & WHILE
Æ unlike while loop the loop condition of do while loop must be followed by a semicolon.
Æ in while if condition is false loop will not execute but n do while even if condition s false the loop will execute at least once.
Æ for & while r pre-tested loop but do while is a post tested loop.
NESTED LOOP
a loop wth in another loop s known as nested loop
for(int i=1; i<=5; i++)
for(int j=1; j<=4; j++)
cout <<i+j <<endl;
CONDITIONS for NESTED LOOP
Ü one outer loop can have 16 inner loop
Ü inner loop must begin & end with in outer loop, if inner loop crosses the boundary of outer loop such errors r not detected by compiler known as semantic errors(meaning errors)