Question: In this C program, you will take command-line arguments of 10 numbers, which are assumed to be integers, and find the median or the average

 In this C program, you will take command-line arguments of 10

In this C program, you will take command-line arguments of 10 numbers, which are assumed to be integers, and find the median or the average of them. The average of the array should be a floating point number (double). Before the numbers on the command line, there will be an argument that indicates whether to find the median (- m) or average (-a), if the user entered an invalid option or incorrect number of arguments, the program should display an error message. To find the median of an array, use the selection_sort function provided above to sort the array, the median is the number that is halfway into the array: a[n/2], where n is the number of the elements in array a.

input and output:

./a.out a 2 6 8 4 9 10 7 3 11 5

output: 6.5

./a.out m 2 6 8 4 9 10 7 3 11 5

output: 7

./a.out

output: usage: ./a.out option (a or m) followed by 10 numbers

./a.out d 2 6 8 4 9 10 7 3 11 5

output: Invalid option

1) Name the program command_line.c

2) Use strcmp function to process the first command line argument.

3) Use atoi function in to convert a string to integer form.

1 selection sort.c, project 6, Program Design 4 #include 5 #define N 10 7 void selection sort (int ai, int n); 9 int main (void) 10 11 int i; 12 int a[N] 13 14 printf( "Enter %d numbers to be sorted. ", N); 15 for (i=0;i a [largest]) largest 1; temp = a [n-1); a [n-1] a [largest]; a [largest] = temp ; 43 45 selection_sort (a, n -1): 46h

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!