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
Why is c fast?
I need previous papers of CSC.......plz help out by posting them.......
What are the rules for identifiers in c?
what is uses of .net
What is the difference between #include and #include 'file' ?
What are the application of c?
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
What is I ++ in c programming?
What are control structures? What are the different types?
How can you find out how much memory is available?
What does 1f stand for?
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.
Explain what are the advantages and disadvantages of a heap?
What are the advantages of using macro in c language?
Why is c so important?