Question: C Programming: Please provide explanation as you work out the code. I want to understand why the code is being used, not just view the
C Programming: Please provide explanation as you work out the code. I want to understand why the code is being used, not just view the code.
I have included project 3 that we are using for this project.
Thank you very much.




!["stats.h" int main(int argc, char* argv[]) { int size, i; char order;](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/6704009dcf417_5496704009d6eb7c.jpg)
stocks.c:
#include
int main(int argc, char* argv[]) { int size, i; char order;
// greet and get the number of stocks print_greeting(); printf("How many stocks prices would you like to analyze? "); scanf("%d", &size);
// read the data float array[size]; read_array(array, size);
// get the stats float mean = get_average(array, size); float variance = get_variance(array, size); float min = get_min(array, size); float max = get_max(array, size); float median = get_median(array, size);
// show the results print_results(array, size, median, min, max, mean, variance);
return 0; }
stats.c
#include
#include "stats.h"
// sorts the values of an array according to order
void sort (float output[], const int size, char order)
{
int i, j;
float temp;
if (order == 'a' || order == 'A')
{
for ( i = 0; i
for ( j = i + 1; j
if ( output[i] > output[j] )
{
temp = output[i];
output[i] = output[j];
output[j] = temp;
}
}
else if (order == 'd' || order == 'D')
{
for ( i = 0; i
for ( j = i + 1; j
if ( output[i]
{
temp = output[i];
output[i] = output[j];
output[j] = temp;
}
}
else
return;
}
io.c
#include
// prompt the user for input and read the values into an array void read_array(float array[], int size) { int i = 0; for (i = 0; i
// say hi to the user void print_greeting(void) { printf("you put whatever greeting you want here "); }
// display array values void print_array(const float array[], int size) { int i = 0;
for (i = 0; i
printf(" ");
}
// print the stat results including input data void print_results(const float array[], int size, float median, float min, float max, float mean, float variance) {
printf(" Say something here about the ouput "); print_array(array, size); printf("median: $%.2f ", median); printf("min: $%.2f ", min); printf("max: $%.2f ", max); printf("variance: $%.2f ", variance); printf("mean: $%.2f ", mean);
}
1. Create a folder with the name lastname_initials-proj4- all lower case. 2. put inside it these files: Makefile, stocks.c, stats.c,io.c, io.h, stats.h, utils.h, utils.c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
