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 can a program be made to print the name of a source file where an error occurs?
How the c program is executed?
What is int main () in c?
Wt are the Buses in C Language
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
string reverse using recursion
What is the difference between strcpy() and memcpy() function in c programming?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
What is pivot in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is a constant?
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
How are portions of a program disabled in demo versions?
What is header file in c?