how to swap four numbers without using fifth variable?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
How can I split up a string into whitespace-separated fields?
Explain what is wrong with this program statement?
Explain the difference between null pointer and void pointer.
what is the differance between pass by reference and pass by value.
how many error occurs in C language ?
What is an example of structure?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
What is the process to generate random numbers in c programming language?
give one ip, find out which contry
What is identifiers in c with examples?
multiple of 9 without useing +,* oprator
What are the two types of functions in c?