C++ Loops

Basics of Loop:

while(condition){
statement;
}

do{
statement;
}while(condition);

for(initialize;condition;increment){
statement;
}

Nested Loops:

while(condition){
do{
statement;
}while();
statement;
}

 

do{
statement;
for(initialize;condition;increment){
statement;
}
statement;
}while(condition);

 

for(initialize;condition;increment){
while(condition)
{
statement;
}
statement;
}

Infinite loop:

Actually we use for loop here

for( ; ; )
{
statement; // it will run forever
}

Control Statement For The loops:

break;//it means stop
continue; //it means continue the next statements without these
goto statement; //jump to somewhere
//example
goto zaki;

zaki:
cout<<"My name is zaki";
It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.