State the difference between WHILE and DO-WHILE with proper syntaх.
Advertisements
प्रश्न
State the difference between WHILE and DO-WHILE with proper syntaх.
Advertisements
उत्तर
|
While |
Do-While |
|---|---|
|
1. The while loop is an entry-controlled loop in which the condition is checked before executing the loop body. |
1. The do-while loop is an exit-controlled loop in which the condition is checked after executing the loop body. |
|
2. The while loop executes its statements only when the specified condition is true. |
2. The do-while loop executes its statements once before checking the specified condition. |
|
3. The while loop may execute zero times if the condition is initially false. |
3. The do-while loop executes at least once, even if the condition is initially false. |
|
4. The while loop does not require a semicolon after the closing brace of the loop body. |
4. The do-while loop requires a semicolon after the while condition. |
|
5. |
5. |
