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

Write a program that reads integers from the keyboard and place them in an array

ID: 3646293 • Letter: W

Question

Write a program that reads integers from the keyboard and place them in an array. The program then will sort the array into ascending and descending order and print the sorted lists. the program must not change the original array or create any other integer arrays. The solution to this problem requires two pointer arrays. The first pointer array is rearranged so that it points to the data in ascending sequence. the second pointer array is rearranged so that it points to the data in descending sequence. The output should be formatted with the three arrays printed as a vertical list next to each other (basically a three column table with headings of "ascending" "original" and "descending") It needs to be in C and not C++

Explanation / Answer

#include const int ASIZE = 5; //constant for the number of integers we can sort const int DESC = 0; //constant to designate the descending sort order const int ASC = 1; //constant to designate the ascending sort order //function declarations: void print_array(int a[], int size); int *array_sort(int source[], int size, int sort_order); int main() { int i; int user_data[ASIZE]; //this is the array that holds the integers the user types in int *asc_sorted; //this is the array pointer that represents the array sorted in ascending order int *desc_sorted; //this is the array pointer that represents the array sorted in descending order printf("Please enter %d integers: ", ASIZE); //prompt user for the integers for (i=0; i
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