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 many types of linked lists what are they? How many types of data structures?
18 Answers BSNL, Pivotal Software,
What is auto keyword in c?
What is openmp in c?
Does c have an equivalent to pascals with statement?
Explain why C language is procedural?
Explain what is the advantage of a random access file?
How can a program be made to print the line number where an error occurs?
What are the 5 types of inheritance in c ++?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
what is c programming?
can we access one file to one directory?
You have an array of n integers, randomly ordered with value 1 to n-1.The array is such that there is only one and one value occurred twice. How will you find this number?