What is y value of the code if input x=10y=5;if (x==10)else if(x==9)else y=8;A.9B.8C.6D.7

This question is related to TCS Interview

Showing Answers 1 - 8 of 8 Answers

sahadev

  • Feb 9th, 2007
 

hey i think so y =5 is correct but i m not sure just see the logic what they are given if x=10 then it will go into that loop then it will not go into any other if lese loops so according to my knowledge is 5 but there is no option as 5

  Was this answer useful?  Yes

naresh

  • Feb 22nd, 2007
 

absolutely ans is 5 b'coz defaultly y is initialised to 5.........
as x==10 os true then it never enters into another loops below of tht and the value is 5...........

  Was this answer useful?  Yes

akshit

  • Jul 30th, 2013
 

Nothing has been returned by the loop that is no expression is governing the iterative statement so wrong question

Code
  1. What is y value of the code if input x=10

  2. y=5;

  3. if (x==10)

  4. else if(x==9)

  5. else y=8;

  6.  

  7. A.9

  8. B.8

  9. C.6

  10. D.7

  Was this answer useful?  Yes

Chinnu Ann Jose

  • Aug 21st, 2013
 

5

  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