Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Run this in c program and pleaseeeeeeeee follow all instructions and show both codes https://autograder.cse.buffalo.edu/courses/EAS240-s18/assessmentshw3/attachments/45 Maximum allowed grace days: One Relevant readings from text: D&D
Run this in c program and pleaseeeeeeeee follow all instructions and show both codes
https://autograder.cse.buffalo.edu/courses/EAS240-s18/assessmentshw3/attachments/45 Maximum allowed grace days: One Relevant readings from text: D&D Chapter 7, K&R Chapter 5 Q1) Write a function that takes an array and its size as inputs, and then sorts the elements of the array in ascending order. For example, if the array contains the values (12,-3,5,4,7), then the array sorted in ascending order will be (-3,4,5, 7,12). In order to sort the array, you must use the following algorithm: (0) Initialize i = 0; (1) Starting at array index i, find the smallest value in the array at or after index i (L.e., any index greater than or equal to i within the proper array bounds). (2) 9%ap the smallest value found in the array with the value at index i; (3) Increment i by one; (4) If i is less than the array size, then repeat the process starting at step (1). You must use the following function prototype: void sort(int array,int size); Note: You must write your function prototype in a header file named libsort.h and you must write your function definition in a source file named libsort.c. We are providing you the main source file sort.c, which you can use to test your function. Do not change any- thing in sort.c. In the same libsort.c, write a function that calculates the median of the array. The me- dian is the "middle" number of a sorting array. If the array size is a even number, the median is the average of two middle numbers. If the array size is an odd number, the median will be equal to the value of the middle number. For example, the array with the even numbers, is given by 11,4,2,5,7,3). After sorting it, the array becomes (1,2,3,4,5,7) and the median will be (3 +4)/2 = 3.50. You must also add the following prototype to libsort.h: float find edian(int arrayD, int size); To compile your code, remember that you must compile both sort.c and libsort.c but not libeort.h. In other words, run 'gce sort.c libsort.c' Hint: To determine wether a number is a even number or odd number, you can use the modulo operator %. If you type 2 The number n is divided by 2 and it will return the remainder. If the remainder is 0, the number will be even. If the remainder is 1, the number 12 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started