Question

Complete the implementation of the array_stats function. This activity will help you learn how to use counter controlled loop• Test plan: Test your program with several input sequences. Your test plan should include the following categories: . An empNotes: • A program similar to your produces the output sequences pictured below. The images illustrate a convenient way to in

Item mean : 9.111111 Item min : 1.333333 Item max 14.000000 The second image shows a run with a large input file, but the lis• Use this test driver to implement and test your function prior to submission #include <stdio.h> #include <stdlib.h> #includ

Use the C programming language to complete

#include <stdio.h>
#include <stdlib.h>
#include <float.h>

// Declare Global variables here.

void array_stats() {
// Insert your solution here.
}

#include <stdlib.h>
#include <time.h>

int main() {
// Simulate the test setup process.
srand( time( NULL ) );
for ( int i = 0; i < 32; i++ ) {
val[i] = rand();
}
val_count = rand();
val_mean = rand();
val_min = rand();
val_max = rand();

// Call submitted code.
array_stats();

// Display contents of array val.
for (int i = 0; i < val_count; i++) {
printf("%f ", val[i]);
}

printf("\n");
printf("Item count: %d\n", val_count);
printf("Item mean : %f\n", val_mean);
printf("Item min : %f\n", val_min);
printf("Item max : %f\n", val_max);

return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <stdlib.h>
#include <float.h>


double val[32];
int val_count=0;
double val_mean=0.000000;
double val_min=0.000000;
double val_max=0.000000;


void array_stats() {
int i;

   val_min=val[0];
for(i=0;i<32;i++)
{   
if(i<32)
{
val_mean=val_mean+val[i];
}
if(val[i]<val_min)
val_min=val[i];
if(val[i]>val_max)
val_max=val[i];

val_count++;
}
  
if(val_count>32)
val_mean=val_mean/32;
else
val_mean=val_mean/val_count;
  
}

#include <stdlib.h>
#include <time.h>

int main() {
  
srand( time( NULL ) );
int i;
for ( i = 0; i <32 ; i++ ) {
val[i] = rand();
}


// Call submitted code.
array_stats();

// Display contents of array val.

for ( i = 0; i < val_count; i++) {
printf("%f ", val[i]);
}
  
printf("\n");
printf("Item count: %d\n", val_count);
printf("Item mean : %f\n", val_mean);
printf("Item min : %f\n", val_min);
printf("Item max : %f\n", val_max);

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Use the C programming language to complete #include <stdio.h> #include <stdlib.h> #include <float.h> // Declare Global...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT