What is y value of the code if input x=10y=5;if (x==10)else if(x==9)elae y=8;a.9b.8c.6d.7

B
This question is related to TCS Interview

Showing Answers 1 - 2 of 2 Answers

sathish

  • Mar 27th, 2007
 

value of y is 8

  Was this answer useful?  Yes

Dinesh

  • Oct 12th, 2007
 

I think value of y = 5.
Because if you format the code, it will look like this
x = 10;
y=5;
if (x==10)
{
}
else if(x==9)
{
}
else
{
   y=8;
}
Since value of x is 10 so condition if (x==10) will satisfy. And there is no assignment for y. So value of y will remain unchanged.
Plz correct me if I'm wrong.

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