The Wayback Machine - https://web.archive.org/web/20230527192432/https://www.geeksforgeeks.org/gate-gate-cs-2014-set-1-question-19/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

GATE | GATE-CS-2014-(Set-1) | Question 19

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Consider the following program in C language:




#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.


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.

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads