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

C programming can you guys help me?! Write a program that prompts the user to in

ID: 3760500 • Letter: C

Question

C programming can you guys help me?!

Write a program that prompts the user to input 3 integer values into the computer. Write a function that re-orders the values in the three integer variables such that the values occur in ascending order.

Specifications:

Use the following function prototype for your sorting function:

void ptr_sort(int *a, int *b, int *c);
Use the following three variables to store your numbers in the main() function:

int x, y, z;
Use the following three pointers to point to the three variables in the main() function:

After you have your integer variables and pointers declared, prompt the user to enter 3 numbers (1 number at a time). Scan in the numbers into the variables using your pointers, and call your ptr_sort() function – whose purpose is to sort the numbers so that x contains the smallest number, y contains the middle number, and z contains the largest number. Then print the results to the screen. You MUST use pointers to do ALL operations relating to scanning, sorting, and printing the numbers.

If you execute the program, the following information should be displayed:

Explanation / Answer

#include<stdio.h>

void ptr_sort(int *a, int *b, int *c)

{

int i,j,k;

i = *a;

j = *b;

k = *c;

  

if(i>j)

{

if(i>k)

{

if(k>j)

{

*a = j;

*b = k;

*c = i;

}

else

{

*a = k;

*b = j;

*c = i;

}

}

else

{

*a = j;

*b = i;

*c = k;

}

}

else

{

if(j>k)

{

if(k>i)

{

*a = i;

*b = k;

*c = j;

}

else

{

*a = k;

*b = i;

*c = j;

}

}

else

{

*a = i;

*b = j;

*c = k;

}

}

  

  

}

int main()

{

int x,y,z;

  

printf("Input 3 numbers : ");

  

printf("Input number 1 : ");

scanf("%d",&x);

  

printf("Input number 2 : ");

scanf("%d",&y);

printf("Input number 3 : ");

scanf("%d",&z);

  

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

  

printf("The sorted numbers are : %d, %d, %d",x,y,z);

}