How many ways are there to swap two numbers without using
temporary variable? Give the each logic.

Answer Posted / vignesh1988i

as for i know their are two different logics for the
swapping techinque.... swapping is a type of techinque used
for interchanging the two varibles in the operating
memory....
1) using only variables
2) using EX-OR operator '^'
first logic only know.
void main()
{
int a,b;
printf("enter the a&b");
scanf("%d%d",&a,&b);
a+=b;
b=a-b;
a-=b;
printf("a=%d\nb=%d",a,b);
getch();
}

Is This Answer Correct ?    48 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I get an accurate error status return from system on ms-dos?

653


Write a program to reverse a given number in c?

603


Explain what are reserved words?

635


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4509


Explain enumerated types.

602






What are the 4 types of programming language?

586


What is difference between array and pointer in c?

542


What are predefined functions in c?

570


Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

1742


What are types of structure?

608


What is property type c?

607


Explain the advantages of using macro in c language?

584


What is meant by 'bit masking'?

890


write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.

1520


What is the argument of a function in c?

579