write a program to swap Two numbers without using temp variable.
Answer Posted / jaspreet singh
hey prasanna the program you hv writen is correct but this
method fails when we give the input as a=32767 and b=1
the correct method is
a^=b^=a^=b
or
a=a^b;
b=a^b;
a=a^b;
it will always return the correct answer even if the input
is a=32767 and b=1...............
| Is This Answer Correct ? | 17 Yes | 17 No |
Post New Answer View All Answers
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
What are the types of data files?
What is New modifiers?
How can I implement sets or arrays of bits?
Write a program to print fibonacci series using recursion?
Tell me what is the purpose of 'register' keyword in c language?
What are the rules for the identifier?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
How do I create a directory? How do I remove a directory (and its contents)?
If I have a char * variable pointing to the name of a function ..
What does int main () mean?
What is the use of void pointer and null pointer in c language?
Explain enumerated types in c language?
What is a structure member in c?
What is array of structure in c?