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
What are the types of operators in c?
What is typedef struct in c?
When should a type cast not be used?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
What extern c means?
What is the difference between functions getch() and getche()?
What are the two types of structure?
cavium networks written test pattern ..
What are runtime error?
Why doesnt the call scanf work?
What are the rules for identifiers in c?
how to count no of words,characters,lines in a paragraph.
What is the translation phases used in c language?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
Is a house a shell structure?