What does the function return? int fun() { i=3; i=6; if(i=6) i=7; return i; }

7

This question is related to Wipro Interview

Showing Answers 1 - 2 of 2 Answers

Nilkanth

  • Mar 24th, 2006
 

6,

b'cas 1=6 in assignment, not comparision

  Was this answer useful?  Yes

dexter7574

  • May 19th, 2007
 

its 7, because even though its only assignment, the control enters the if block, though its assignment its not a false stmt, so once control enters the if block i=7, so return value is 7 and not 6. :)

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