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
Explain how can I open a file so that other programs can update it at the same time?
What is the collection of communication lines and routers called?
Explain 'bus error'?
What is structure in c language?
What does struct node * mean?
What is the difference between local variable and global variable in c?
Are comments included during the compilation stage and placed in the EXE file as well?
while initialization of array why we use a[][2] why not a[2][]...?
write a programming in c to find the sum of all elements in an array through function.
Explain about the constants which help in debugging?
What is const keyword in c?
Should a function contain a return statement if it does not return a value?
Explain what is the stack?
What is difference between stdio h and conio h?
What is the difference between array and structure in c?