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

What does a pointer variable always consist of?

669


What is break statement?

639


State the difference between realloc and free.

641


What is the basic structure of c?

565


What is the condition that is applied with ?: Operator?

667






How do you use a pointer to a function?

642


Can we initialize extern variable in c?

641


Describe the difference between = and == symbols in c programming?

784


main() { printf("hello"); fork(); }

701


Where is volatile variable stored?

657


What are identifiers and keywords in c?

580


Is c procedural or functional?

593


What do you mean by a sequential access file?

631


What is the difference between single charater constant and string constant?

629


What is the use of sizeof () in c?

567