how to swap four numbers without using fifth variable?

Answer Posted / srinija jilugu

#include<stdio.h>
void main()
{
int a,b,c,d;
printf("enter values\n");
scanf("%d %d %d %d",&a,&b,&c,&d);
printf("before swapping\n");
printf("%d %d %d %d",a,b,c,d);
a=(a+b);
b=(a-b);
a=(a-b);
c=(c+d);
d=(c-d);
c=(c-d);
printf("after swapping:%d %d %d %d",&a,&b,&c,&d);
}

Is This Answer Correct ?    23 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5571


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2849


Tell me with an example the self-referential structure?

654


How can you return multiple values from a function?

726


Why array is used in c?

655






Why is void main used?

700


How the c program is executed?

736


What is the time and space complexities of merge sort and when is it preferred over quick sort?

773


Give the rules for variable declaration?

773


what is the role you expect in software industry?

1752


Should a function contain a return statement if it does not return a value?

687


Where is c used?

733


What is maximum size of array in c?

676


What is malloc return c?

684


What does the message "automatic aggregate intialization is an ansi feature" mean?

790