Which of the following statements is/are true?
(1)The initialise counter sets for loop to initial value.
(2) The while loop executes the body of loop at least once regardless of the logical condition.
(3) The body of the for loop requires the braces even if we are writing only one statement after the for loop.
-
Only (1)
-
Only (2)
-
Only (3)
-
Both (1) & (2)
-
Both (1) & (3)
A
Correct answer
Explanation
The initialize counter of for loop sets the loop to initial value.
For example: for (i =0; i<10; iH), loop initializes to zero. So, statement (1) is correct.
The do while loop executes the body of loop at least once regardless of the logical condition. So, statement (2) is incorrect.
The body of for loop does not require braces if there is only one statement after for loop. So, statement (3) is incorrect.
Hence, option (1) is correct.