Consider the following program in C: The output of the program is _________.…

2026

Consider the following program in C:

image.png

The output of the program is _________. (answer in integer)

Note: Assume that the program compiles and runs successfully.

Attempted by 201 students.

Show answer & explanation

Correct answer: 9

1. In main(), i = 9 and j = 10. func(9, 10) is called.

2. Inside func(), parameter i = 9, j = 10.

3. if (9 < 10) is true. int i = 0 declares a new local variable i, shadowing the parameter i.

4. The while loop modifies the new local i and parameter j. Parameter i remains 9.

5. After the if block, the new local i is out of scope. printf prints the parameter i, which is 9.

Explore the full course: Gate Guidance By Sanchit Sir