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
Explain what are the different data types in c?
What do mean by network ?
What is string length in c?
What is volatile c?
given post order,in order construct the corresponding binary tree
What is a stream?
What are the 5 elements of structure?
What is an expression?
Why c language?
What is abstract data structure in c?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
What are dangling pointers in c?
What should malloc(0) do?
Can 'this' pointer by used in the constructor?
What is declaration and definition in c?