what is difference between while loop,for loop and do while loop

The basic difference between them is as follows:

1.When we want a condition must be true before entering a loop we must use while loop as it runs as long as the certain condition is passed and if condition is true it runs other wise it gets false.

the structure of while loop as follow:

While:

  • Read the loop
  • But first checks the condition
  • If condition is met as false
  • It stops
  • It never runs even one time if condition is false
  • It is more strict than what is DO WHILE loop
  • there is no semicolon at the end of while statement

   2. Do-while:

When we want to enter the loop minimum for one time we must use use do while loop as it runs first then checks the condition and afterwards if it finds the condition is not true then it does not work.It means it runs minimum for one time.
the structure of do while loop

  •  Runs the loop
  • executes once the loop
  • afterwards if condition is met as false
  • it stops
  • and fails

 3. OR loop runs a pre-defined number of times

   Hopes it may solve your initial programming concept and lead to further development !
     Thanks for reading !