Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

sort.c #include #include #include libsort.h int main() { int* array; int size, c; float median; printf(Enter the array size: ); scanf(%d, &size); array = (int*)

image text in transcribed

sort.c

#include #include #include "libsort.h"

int main() { int* array; int size, c; float median;

printf("Enter the array size: "); scanf("%d", &size);

array = (int*) malloc(size * sizeof(int));

printf("Enter %d integers: ", size);

for (c = 0; c

sort(array, size);

printf("Array sorted in ascending order: "); for (c = 0; c

printf(" "); median = find_median(array, size); printf("The median is: %.1f ", median);

return 0; }

Q2) Write a program that takes the average and variance of an array. The average and variance are calculated by: run the following command in your terminal, in the same directory as your sort.c file. This command will create a new file that you are to change and submit: sed '3d; 9d;21,30d' sort.c avg-var.c The sed command is used to remove lines from a file, while the> stores the output of a command (whatever is printed in the terminal) to a new file. The '3d9d:21,30d' argument states to remove lines 3, 9, and 21-30 from the sort.c file. avg-var.c is now the code to request a size of an array, allocate memory for the array, and fill the array. You must add functionality by adjusting the code to calculate the average and variance of the array. All lines added to the code must be after line 18. Print the average and variance such that the output appears as below (there are NO double spaces): Enter the array size: 3 Enter 3 integers: 1 2 3 The average is 2.00 The variance is: 0.67 Q2) Write a program that takes the average and variance of an array. The average and variance are calculated by: run the following command in your terminal, in the same directory as your sort.c file. This command will create a new file that you are to change and submit: sed '3d; 9d;21,30d' sort.c avg-var.c The sed command is used to remove lines from a file, while the> stores the output of a command (whatever is printed in the terminal) to a new file. The '3d9d:21,30d' argument states to remove lines 3, 9, and 21-30 from the sort.c file. avg-var.c is now the code to request a size of an array, allocate memory for the array, and fill the array. You must add functionality by adjusting the code to calculate the average and variance of the array. All lines added to the code must be after line 18. Print the average and variance such that the output appears as below (there are NO double spaces): Enter the array size: 3 Enter 3 integers: 1 2 3 The average is 2.00 The variance is: 0.67

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions