GeekInterview.com
Series: Subject: Topic:
Question: 207 of 238

find the output of the following program
main()
{
int x=5, *p;
p=&x;
printf("%d",++*p);
}
a.5
b.6
c.0
d.none

B
This question is related to TCS Interview
Asked by: Interview Candidate | Asked on: Nov 18th, 2002
Showing Answers 1 - 2 of 2 Answers
Meena Goel

Answered On : Sep 12th, 2007

The answer for this question is 6. in starting the value of x is 5 that will be incremented by pointer p.

Yes  1 User has rated as useful.
  
Login to rate this answer.
rizwann

Answered On : Jan 28th, 2012

View all answers by rizwann

This ques tests your knowledge of operator precedence and associativity

* and ++ operator have same precedence and their associativity is right to left.

That is why first (*p) is evaluated which results 5 then (++*p) i.e. (++5) is evaluated which gives us 6

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.