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

B
This question is related to TCS Interview

Showing Answers 1 - 2 of 2 Answers

Meena Goel

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

rizwann

  • Jan 28th, 2012
 

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

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions