GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Siemens  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 4 of 35    Print  
For the following C program:

swap(int x, int y)

{ int temp;

temp=x;

x=y;

y=temp;}

main()

{int x=2;y=3;

swap(x,y);}

After calling swap, what are the values x & y?



  
Total Answers and Comments: 7 Last Update: June 03, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 22, 2005 05:04:34   #1  
Sachin Chakote        

RE: For the following C program:swap(int x, int y){ int temp;temp=x;x=y;y=temp;}main(){int x=2;y=3;swap(...
The values of x and y will be same since there scope is local the swapping done inside swap() function is not reflected inside main().


 
Is this answer useful? Yes | No
July 25, 2005 11:59:38   #2  
shanmugam        

RE: For the following C program:swap(int x, int y){ int temp;temp=x;x=y;y=temp;}main(){int x=2;y=3;swap(...
x 2
y 3

 
Is this answer useful? Yes | No
November 10, 2006 06:08:39   #3  
vaseef        

RE: Question wrong
here the question it self has syntax error.swap (int x int y) is required.. in question swap(int x y) is given.If we correct the line and execute the pgm the values will not be swapped in main().so values will be x 2;y 3;
 
Is this answer useful? Yes | No
January 27, 2007 03:31:37   #4  
KALAI        

RE: For the following C program:swap(int x,y)
answerthe value of x and y will be d same because the swap() doesn't have a return statement.......
 
Is this answer useful? Yes | No
February 07, 2008 01:16:14   #5  
ramyashreebharadwaj Member Since: February 2008   Contribution: 1    

RE: For the following C program:swap(int x, int y){ int temp;temp=x;x=y;y=temp;}main(){int x=2;y=3;swap(x,y);}After calling swap, what are the values x & y?
here the value of x 2 and y 3...as in it does not change because here only the values are passed as arguments....for the values to get changed a referece to the variables has to be passes as an argument
 
Is this answer useful? Yes | No
March 13, 2008 09:24:50   #6  
Ananth_kumar12 Member Since: March 2008   Contribution: 1    

RE: For the following C program:swap(int x, int y){ int temp;temp=x;x=y;y=temp;}main(){int x=2;y=3;swap(x,y);}After calling swap, what are the values x & y?
x 3 y 2
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 2Overall Rating: -2    
June 03, 2008 09:57:53   #7  
sandeepdevasrii Member Since: June 2008   Contribution: 1    

RE: For the following C program:swap(int x, int y){ int temp;temp=x;x=y;y=temp;}main(){int x=2;y=3;swap(x,y);}After calling swap, what are the values x & y?
x 2 and y 3
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
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