Differentiate between for loop and while loop?
Answer:
For loop |
While loop |
The for statement is used to iterate over a range of values or a sequence . |
The while statement executes a block of code repeatedly as long as the control condition of the loop is true. |
It is called a definite loop. |
It is called an indefinite loop. |
Flowchart:
|
Flowchart:
|