Write a program to exchange two variaables without temp
Answers were Sorted based on User's Feedback
Answer / sujith
another quick way is,
void main()
{
int a = 10, b = 5;
a ^= b ^= a ^= b;
}
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / kadher
void main()
{
int a=10,b=5;
a=a^b;
b=a^b;
a=a^b;
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / srinivas
main()
{
int a=3,b=2;
a = (a+b)-(b=a);
printf("a=%d,b=%d",a,b);
}
o/p:- a=2,b=3
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / vijay
Sir,... im not comfortable with the 2nd ans cud pls explain
me .?????/
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / haihere
Ans 3 is proper answer,coz in 1 it wont check for
range,,ans 3 is the rigt..
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sandeep rehlan
Sir, please explain me the 3rd and 6th answer because both
are the orrect way of swapping of two variables.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is an expression?
Can you define which header file to include at compile time?
How can I find out how much free space is available on disk?
void main() { int a=1; printf("%d %d %d",a,++a,a++); } the output is supposed to be 1 2 2....but it is 3 3 1 this is due to calling conventions of C. if anyone can explain me how it happens?
what is the benefit of c30
What is difference between far and near pointers?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
What is calloc() function?
Why is c faster?
Explain how can I avoid the abort, retry, fail messages?
What are # preprocessor operator in c?
what is the diference between pointer to the function and function to the pointer?