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 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 #includeStep 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