how to swap two integers 1 and 32767 without using third
variable
Answer Posted / mansi_engg
use unsigned before variable a and b in
a=1;
b=32767;
a=a+b;
b=a-b;
a=a-b;
bcoj 32767+1 =32768 which goes out of range of integer and
will be stored as -32768 which wil make the swapping
wrong.by using unsigned, addition will come in range 0-65536
and thus the process works.
Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
Is c pass by value or reference?
Where register variables are stored in c?
what is the structure pointer?
What’s a signal? Explain what do I use signals for?
Why isnt there a numbered, multi-level break statement to break out
What is static identifier?
What is static function in c?
Why is c faster?
Why c language is called c?
What is the difference between %d and %i?
What are the benefits of c language?
What is difference between union and structure in c?
Explain the difference between #include "..." And #include <...> In c?
What is the use of the function in c?
can anyone suggest some site name..where i can get some good data structure puzzles???