The code is about that takes the addresses of three double variables as arguments and that moves the value of the smallest variable into the first variable, the middle value to the second variable, and the largest value into the third variable.
#include<stdio.h>
void swapy(double *x, double *y, double *z);
int main()
{
double no1,no2,no3;
printf("Enter three numbers\n");
printf("no1 = ");
scanf("%lf",&no1);
printf("no2 = ");
scanf("%lf",&no2);
printf("no3 = ");
scanf("%lf",&no3);
swapy(&no1,&no2,&no3);
printf("The numbers will be printed in increasing order!\n");
printf("no1 = %lf\n",no1);
printf("no2 = %lf\n",no2);
printf("no3 = %lf\n",no3);
}
void swapy(double *x, double *y, double *z)
{
double *max;
double *mid;
double *min;
if(*x>*y && *x>*z) {
*max = *x;
}
else if(*y>*x && *y>*z) {
*max = *y;
}
else {
*max = *z;
}
if(*x<*y && *x<*z) {
*min = *x;
}
else if(*y<*x && *y<*z) {
*min = *y;
}
else {
*min = *z;
}
if(*x != *max && *x != *min) {
*mid = *x;
}
else if(*y != *max && *y != *min) {
*mid = *y;
}
else {
*mid = *z;
}
*x = *min;
*y = *mid;
*z = *max;
return;
}
the code is about that takes the addresses of three double variables as arguments and that moves the value of the smallest variable into the first variable, the middle value to the second variable, and the largest value into the third variable.