In terms of the functionality both for and while loops have same usage.
So, why both are used
Difference between for and while loops in c-programming?
The while loop repeats a set of instructions while a condition is met. The for loop repeats a set of instructions a set number of times only.
Reply:while loop repeats certain statements based on the condition checked
for loop helps in initialisation of a variable and repeats certain statements based on condition checked and also helps in increment/decrement of the variable
Reply:We can get out of the while loop with a break statement only...!Whereas in for loop if the condition is false it will come out..!Clear..!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment