loop in C++

Loop?

It is the repetition of a code more than once We must have a condition within a code, you must provide a counter. It comes in three types:





1-for loop


for(int i=0;i<10;i++)
{
cout<<i;
}


2-while



int x=1;
while(x>=10)
{
cout<<x;
x++
}


3-do while


int x=0;
do
{
cout<<x;
x++
}while(x>=10);



different between while and do while?

while entering the condition then code 
do while Reversal while entering the code then condition

nested loop?

it is loop inside loop It was a type of loop. for example:

for(int i=0;i<=10;i++)
    for(int j=0;j<=10;j++)
        cout<<i<<" "<<j;

Previous Post Next Post