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 |
Write a program to generate the first n terms in the series --- 2,3,5,7,11,...,17
Which programming language is best for getting job 2020?
Explain the use of keyword 'register' with respect to variables.
write a program to fined second smallest and largest element in a given series of elements (without sorting)
what are two categories of clint-server application development ?
Where register variables are stored in c?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
What is the purpose of void pointer?
How to implement call back functions ?
print out of string in this format; 1. "rajesh" 2. \n 3. %d
Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc
is compiler do read the data line by line or not. ??
6 Answers LG Soft, Satyam, Tech Mahindra,