Correct Answer : A
Execution of program starts from main
. Inside main
is an integer variable i
declared and initialized to 7
. The next statement is a for
loop where the initialization part, termination part and increment part is empty. Inside for is an if having condition i < 4
. If condition is satisfied, then control goes out of for
loop since break
is present. The next statement is a display statement which prints i
for every iteration and then i
is decremented.
Iteration 1 :
if
condition returns false
. Display is executed and i = 7
is printed. i
is decremented to 6
.
Iteration 2 :
if condition returns false
. Display is executed and i = 6
is printed. i
is decremented to 5
.
Iteration 3 :
if condition returns false
. Display is executed and i = 5
is printed. i
is decremented to 4
.
Iteration 3 :
if condition returns false
. Display is executed and i = 4
is printed. i
is decremented to 3
.
For next statement as 3 < 4
is true
. So break
is executed and control goes out of for
loop.