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 %g in c?
How will you write a code for accessing the length of an array without assigning it to another variable?
how to execute a program using if else condition and the output should enter number and the number is odd only...
In which header file is the null macro defined?
What do you mean by scope of a variable in c?
what is the difference between class and unio?
What is pointer in c?
How can I prevent another program from modifying part of a file that I am modifying?
What is the heap?
What is auto keyword in c?
What is the use of ?: Operator?
How do you define a string?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
Why isnt any of this standardized in c?
Write a program to check prime number in c programming?