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

Hi there, Please do this in C!! We didn\'t go over arrays (that\'s next week), s

ID: 3631735 • Letter: H

Question

Hi there,

Please do this in C!! We didn't go over arrays (that's next week), so please don't use em!


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

Hi, i can only provide the algorithm as i never learn C programming. hope it helps

   IF (a < b) THEN                 ! a < b here
      IF (a < c) THEN              !   a < c     : a the smallest
         IF (b < c) THEN           !      b < c : a < b < c
            WRITE(*,*) a, b, c
         ELSE                    !      c <= b : a < c <= b
            WRITE(*,*) a, c, b
         END IF
      ELSE                           !   a >= c    : c <= a < b
         WRITE(*,*) c, a, b
      END IF
   ELSE                            ! b <= a here
      IF (b < c) THEN              !   b < c     : b the smallest
         IF (a < c) THEN           !     a < c   : b <= a < c
            WRITE(*,*) b, a, c
         ELSE                        !     a >= c : b < c <= a
            WRITE(*,*) b, c, a
         END IF
      ELSE                       !   c <= b    : c <= b <= a
         WRITE(*,*) c, b, a
      END IF
   END IF

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