Welcome Guest | Sign in | Register
Functions - Discussion Page For Q.10738 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Functions > Questions and Answers

Q: What is the output of the following code?
int swap(int *a,int *b)
{
*a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
int x=10,y=20;
swap(&x,&y);
printf("x= %d y = %d\n",x,y);
}
A. x = 10 y = 10 B. x = 20 y = 20
C. x = 02 y = 01 D. x = 20 y = 10

Answer and Explanation

Answer:x = 20 y = 10

Explanation:
This is one way of swapping two values. Simple checking will help understand this.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.