write a program in C to swap two variables
Answer Posted / muzammil
Here are some LOGICS to swap two nmbrs
1) a+=b; b=a-b; a-=b;
2) a*=b; b=a/b; a/=b;
3) a=a^b; b=a^b; a=a^b;
Now Single line statements
4) a=a-(b=(-b+(a=a+b)));
5) a=a^(b=(b^(a=a^b)));
6) b=a+b-(a=b); This one was posted BY Senthil Thanks to him
7) b=a*b/(a=b); Dis is same as above one except for da
operators.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
How do we make a global variable accessible across files? Explain the extern keyword?
What are the main characteristics of c language describe the structure of ac program?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Explain what are binary trees?
Explain how can I pad a string to a known length?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
Explain what are its uses in c programming?
What is the use of header?
What are terms in math?
What are keywords in c with examples?
Write a program to check prime number in c programming?
How variables are declared in c?
What is a null string in c?
Explain the Difference between the New and Malloc keyword.