Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi there, if you can do this in C, I\'d appreciate that. We just finished pointe

ID: 3631569 • Letter: H

Question

Hi there, if you can do this in C, I'd appreciate that. We just finished pointers, but haven't gone over arrays yet.

Write a program that orders three double numbers by increasing value. The program should include a function named sort3 that takes three double * arguments (pointer to double). The function prototype is

void sort3(double *x, double *y, double *z);

The function should reorder the values pointed to by its arguments so that after the call

sort3(&x, &y, &z);

the numbers x, y,z satisfy x<=y<=z.

Your program should input data and print results using the following format:

Enter three numbers: 4.7 1.4 3.2
The ordered sequence is: 1.4 3.2 4.7

Explanation / Answer

/* This may help you*/

 

#include<iostream>
using namespace std;
void sort3(double *x,double *y, double *z)
{
double x=0.0,y=0.0,z=0.0;
x=*x;
y=*y;
z=*z;
if((x>y)&&(x>z))
    {
    if((y>z)&&(y>x))
    {
    cout<<z<<y<<x;
    }   
   
    }
else if((y>x)&&(y>z))
    {
    if((z>x)&&(z>y))
    {
    cout<<x<<z<<y;
    }
    }
else
{
if((x>y)&&(x>z))
{
cout<<y<<x<<z;
}
}



}
int main()
{
double x=0.0,y=0.0,z=0.0;
cout<<"Enter the values of x,y,z";
cin>>x>>y>>z;
sort3(&x,&y,&z);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote