how to swap four numbers without using fifth variable?
Answer Posted / rocky
#include<stdio.h>
void main()
{
int a,b,c,d;
printf("enter values
");
scanf("%d %d %d %d",&a,&b,&c,&d);
printf("before swapping
");
printf("%d %d %d %d",a,b,c,d);
a=(a+d);
d=(a-d);
a=(a-d);
c=(c+b);
b=(c-b);
c=(c-b);
printf("after swapping:%d %d %d %d",a,b,c,d);
}
| Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
What is the difference between class and object in c?
What is array of structure in c programming?
Explain threaded binary trees?
Can a file other than a .h file be included with #include?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What are the advantages of using Unions?
In C language, a variable name cannot contain?
How many main () function we can have in a project?
Write program to remove duplicate in an array?
What are volatile variables in c?
In C, What is the #line used for?
Why is not a pointer null after calling free?
What language is lisp written in?
What should malloc() do?
If I have a char * variable pointing to the name of a function ..