Explain The Basic Difference Between For And While Loop With And Example?

1

1 Answers

Alongbar Daimary Profile
Oh!!!
The basic Difference between for and while loop is:
When we are using for loop it is required to know that how many times we need to repeat.
But in case of while loop it is not so.

Example:
For(int I=1 ;I<=10;I++) // here we already know that the loop will continue 10 times.
{
//statement
}

boolean ABC=false;
while(!ABC)  // Here we don't know when its execution will stop.
{
//Statement.
}

Answer Question

Anonymous