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

Answer Posted / venkatesh sabinkar

as far i know i know two logics they are
first one
void main()
{
int a,b;
printf("eneter any two values");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("a=%d\nb=%d",a,b);
getch():
}
second one
void main()
{
int a,b;
printf("eneter any two values");
scanf("%d%d",&a,&b);
a=a*b;
b=a/b;
a=a/b;
printf("a=%d\nb=%d",a,b);
getch():
}

Is This Answer Correct ?    24 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c fast?

612


I need previous papers of CSC.......plz help out by posting them.......

1818


What are the rules for identifiers in c?

592


what is uses of .net

1279


What is the difference between #include and #include 'file' ?

610






What are the application of c?

652


a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

631


What is I ++ in c programming?

630


What are control structures? What are the different types?

602


How can you find out how much memory is available?

620


What does 1f stand for?

616


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3343


Explain what are the advantages and disadvantages of a heap?

599


What are the advantages of using macro in c language?

596


Why is c so important?

598