:
#include <stdio.h>main(){ int i; int *pi = &i; scanf("%d", pi); printf("%d\n", i+5);} |
Which one of the following statements is TRUE?
(A) Compilation fails.
(B) Execution results in a run-time error.
(C) On execution, the value printed is 5 more than the address of variable i.
(D) On execution, the value printed is 5 more than the integer value entered.
(A) Compilation fails.
(B) Execution results in a run-time error.
(C) On execution, the value printed is 5 more than the address of variable i.
(D) On execution, the value printed is 5 more than the integer value entered.
Answer: (D)
Explanation: There is no problem in the program as pi points to a valid location.
Also, in scanf() we pass address of a variable and pi is an address.
Explanation: There is no problem in the program as pi points to a valid location.
Also, in scanf() we pass address of a variable and pi is an address.
No comments:
Post a Comment