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
Explain what is wrong with this program statement?
What is the difference between c and python?
what are the 10 different models of writing an addition program in C language?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What is main () in c?
What is const and volatile in c?
c program for searching a student details among 10 student details
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
Are pointers integer?
to find the closest pair
What is static volatile in c?
Can the “if” function be used in comparing strings?
Can include files be nested? How many levels deep can include files be nested?
How does sizeof know array size?