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
What does int main () mean?
What do you mean by keywords in c?
What is a newline escape sequence?
Is main is a keyword in c?
Is c is a low level language?
Explain what is wrong in this statement?
What is the use of header files?
What is the difference between union and structure in c?
Can include files be nested?
What is the translation phases used in c language?
please explain every phase in the "SDLC" in the dotnet.
What is the auto keyword good for?
Differentiate between #include<...> and #include '...'
about c language
Write a program to know whether the input number is an armstrong number.