What are Loop statements or Iteration Statements?

Loop statements are used to execute certain set of statements again and again in a program.
Different types of Loops:
1. While loop: While loop is used to execute the statements within it till the condition is true.
Syntax:
while(condition)
{
Statements;
}
2. Do while loop: Do while loop is also used to execute the statements till the condition is true but in this loop, statements will be executed first after that the condition will be checked. It will execute the statements at least one time even if the condition is false at the beginning.
Syntax:
do
{
statements;
}
While (condition);
3. For loop : In For loop, all the three parts of the loop that is initialization, condition and iteration are all written in a single statement. Initialization means initial value given to variable, condition upto which loop will execute and iteration is increment or decrement of value of variable.
Syntax:
For(initialization; condition; iteration)
{
Statements;
}

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.