Correct Answer : C
Inside main
two integer variables, sum
and i
are declared and initialized to 5
and 1
respectively. The next statement is a for
loop with empty initialization part and has a terminating condition : i < 4
. There are 2 more for
loops nested inside this loop. The first nested loop has initialization condition j = 1
and terminating condition j < 4
. The second nested loop has initialization condition of k = 1
and terminating condition k < 4 - 1 = 3
and increment value 1(k++
). For every iteration, sum
is multiplied with i * j
. Then i
, j
, k
are incremented sequentially.
For each iteration, value of sum
will be as follows:
sum = 5 * 1 * 1 = 5
sum = 5 * 2 * 2 = 20
sum = 20 * 3 * 3 = 180
Then loops terminate since the values of i
, j
and k
will be 4
and none of the termination conditions satisfy. So the value Sum = 180 will be displayed using display statement.