how to swap two integers 1 and 32767 without using third
variable
Answer Posted / sharath kumar
As int max valur is 32767. If we increment it it becomes -32768, so its a wrong way to do
a=1; b=32767;
a=-a; b=-b;
a=a+b; //-32768 with in range
b=a-b; //-1
a=a-b; //-32767
printf("%d%d",-a,-b);
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Why should I use standard library functions instead of writing my own?
Write a Program to accept different goods with the number, price and date of purchase and display them
Write a program to show the change in position of a cursor using c
What is the use of typedef in c?
Tell us the use of fflush() function in c language?
What is the difference between declaring a variable by constant keyword and #define ing that variable?
How do you list files in a directory?
What is wrong with this program statement?
What is a struct c#?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Compare and contrast compilers from interpreters.
What is the general form of a C program?
In a byte, what is the maximum decimal number that you can accommodate?
In C, What is the #line used for?
What is the difference between struct and union in C?