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
how logic is used
What is auto keyword in c?
What is echo in c programming?
Explain null pointer.
Explain the difference between null pointer and void pointer.
Explain logical errors? Compare with syntax errors.
Here is a good puzzle: how do you write a program which produces its own source code as output?
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
What is a floating point in c?
What does 3 periods mean in texting?
Differentiate fundamental data types and derived data types in C.
Do pointers need to be initialized?
Here is a neat trick for checking whether two strings are equal
How will you declare an array of three function pointers where each function receives two ints and returns a float?
How do I use void main?