StreakPeaked· Practice

ExamsGATETechnical

Consider the following program in C language: #include <stdio.h> main() { int i; int *pi = &i; scanf("%d", pi); printf("%d ", i+5); } Which one of the following statements is TRUE?

  1. Compilation fails.
  2. Execution results in a run-time error.
  3. On execution, the value printed is 5 more than the address of variable i.
  4. On execution, the value printed is 5 more than the integer value entered.

Correct answer: On execution, the value printed is 5 more than the integer value entered.

Solution

The program correctly reads an integer value into the variable 'i' using a pointer, and then it prints the value of 'i' increased by 5, which means the output is indeed 5 more than the integer value entered by the user.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →