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
Hi can anyone tell what is a start up code?
What are pointers? Why are they used?
What are the types of arrays in c?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
What tq means in chat?
Can a variable be both constant and volatile?
What is structure packing in c?
will u please send me the placement papers to my mail???????????????????
Explain how can I convert a string to a number?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What is the difference between union and structure in c?
Who developed c language?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What does printf does?
How variables are declared in c?