how to swap two integers 1 and 32767 without using third
variable
Answer Posted / mansi_engg
use unsigned before variable a and b in
a=1;
b=32767;
a=a+b;
b=a-b;
a=a-b;
bcoj 32767+1 =32768 which goes out of range of integer and
will be stored as -32768 which wil make the swapping
wrong.by using unsigned, addition will come in range 0-65536
and thus the process works.
| Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
write a program to display all prime numbers
application attempts to perform an operation?
What is the use of a semicolon (;) at the end of every program statement?
What is wild pointer in c?
How can you be sure that a program follows the ANSI C standard?
With the help of using classes, write a program to add two numbers.
How can my program discover the complete pathname to the executable from which it was invoked?
Explain what is a pragma?
What is "Duff's Device"?
1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
Why does the call char scanf work?
What is difference between array and pointer in c?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What are the types of arrays in c?