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 pointers are declared?
What is the difference between the expression “++a” and “a++”?
What is the use of getch ()?
Explain the meaning of keyword 'extern' in a function declaration.
Write the Program to reverse a string using pointers.
Should I learn c before c++?
Where in memory are my variables stored?
Why is c used in embedded systems?
What is calloc in c?
What is typedef example?
What does s c mean in text?
Is it possible to have a function as a parameter in another function?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
how to write a c program to print list of fruits in alpabetical order?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.