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
What is the difference between arrays and pointers?
What is the meaning of c in c language?
What is static and auto variables in c?
How does free() know explain how much memory to release?
Does c have an equivalent to pascals with statement?
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
What is the use of the function in c?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What are types of structure?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What is meant by type specifiers?
Is c call by value?
What is the role of this pointer?
Is there sort function in c?
What is this pointer in c plus plus?