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
C language questions for civil engineering
What are the ways to a null pointer can use in c programming language?
What are pointers? What are different types of pointers?
Explain what is wrong in this statement?
What is the advantage of c?
Explain how can type-insensitive macros be created?
What is data structure in c programming?
What are the different types of constants?
What is c preprocessor mean?
What is the meaning of c in c language?
Find MAXIMUM of three distinct integers using a single C statement
write a program to find the given number is prime or not
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
Can you write the algorithm for Queue?
Explain b+ tree?