हिंदी

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. while (condition) { // Statements to be executed }

5. do { // Statements to be executed } while (condition);

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 7: Statements and their Scope - EXERCISE [पृष्ठ १६३]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 7 Statements and their Scope
EXERCISE | Q 7. | पृष्ठ १६३
Advertisements
Share
Notifications



      Forgot password?
Use app×