GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 42 of 87    Print  
What is the value of y in the following code?
x=7;
y=0;
if(x=6) y=7;
else y=1;

A. 7
B. 0
C. 1
D. 6


  
Total Answers and Comments: 3 Last Update: August 22, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 08, 2005 02:19:17   #1  
nitin        

RE: What is the value of y in the following code?...

Look at the code carefully

if(x 6) and not if(x 6).

So after this instruction x will be made equal to 6 and next instruction will follow which will make y 7. So the ans is 7..


 
Is this answer useful? Yes | No
January 11, 2007 08:03:28   #2  
Chithambaram.P Member Since: December 2006   Contribution: 4    

RE: What is the value of y in the following code?...
Answer is y 7 Becoz here we r assigning the value to x 6 not checking condition we will see the operator meaning carefully
 
Is this answer useful? Yes | No
August 22, 2007 06:59:20   #3  
rohit dwivedi9450 Member Since: March 2007   Contribution: 44    

RE: What is the value of y in the following code?...
scope of x 6 will take precedenc on x 7so y 7
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape