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
What is switch in c?
What is pass by value in c?
What is the benefit of using an enum rather than a #define constant?
What is infinite loop?
What is the use of putchar function?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
What are preprocessor directives in c?
Why are all header files not declared in every c program?
What are the scope of static variables?
What is the difference between new and malloc functions?
What is the sizeof () a pointer?
What is the difference between if else and switchstatement
Is null valid for pointers to functions?
In a switch statement, explain what will happen if a break statement is omitted?
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.