HEYLOOO
TELL MEH THE DIFFERENCE BETWEEN WHILE AND FOR LOOP
Answers
Answered by
1
both for and while loop are used to execute one or more lines of code certain no. of times.
Difference is in only with their respective syntaxes..✌️
Difference is in only with their respective syntaxes..✌️
sayyedfaisal06:
For loop is used to execute same line many times but while loop is used to execute a line only till a given condition
Answered by
4
(1)
⇒ 'For loop' is used when the number of iterations are known.
⇒ 'While loop' is used when the number of iterations are unknown.
(2)
⇒ For loop Syntax:
for(initialization;condition;iteration)
{
//body
}
⇒ While loop Syntax:
while(condition)
{
statements;
}
(iii)
⇒ For loop - Keeps on looping until the number of iterations are completed.
⇒ While loop - Keeps on looping until the condition presented is completed.
Hope it helps!
Similar questions