Welcome Guest | Sign in | Register
Pointers - Discussion Page For Q.10746 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Pointers > Questions and Answers

Q: Predict the output or error(s) for the following?

main()
{
int *j;
{
int i=10;
j=&i;
}
printf("%d",*j);
}
A. 8 B. 0
C. 9 D. 10

Answer and Explanation

Answer:10

Explanation:
The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main function. Since the i is still allocated space, *j prints the value stored in i since j points i.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.