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
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Difference between exit() and _exit() function?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What do you mean by a local block?
What is a floating point in c?
what is the basis for selection of arrays or pointers as data structure in a program
How to Throw some light on the splay trees?
How can I write a function analogous to scanf?
What is wrong with this program statement?
What is the use of getch ()?
Are local variables initialized to zero by default in c?
What does return 1 means in c?
What is meant by 'bit masking'?
List some basic data types in c?
What is the purpose of the statement: strcat (S2, S1)?