* Assignment: Practical Exam 2 Retake, Problem 2 Date: April 29, 2015 * Programm
ID: 656381 • Letter: #
Question
* Assignment: Practical Exam 2 Retake, Problem 2 Date: April 29, 2015 * Programmer: <fill in your name)> */
#include <stdio.h> #include <stdlib.h>
#define NUM_IN_LINE 5
/* Function prototypes */ void read_numbers (int capacity, double an_array[], int *count); void print_numbers (const double an_array[], int num_elements);
int main () {
return 0; } /* end main */
/* FUNCTION compute_array_average CODE GOES HERE * ----------------------------------- */
/* FUNCTION compute_array_deviation CODE GOES HERE * ----------------------------------- */
/* Function: read_numbers - reads values from keyboard until a negative number * and stores them in an array up to capacity */ void read_numbers (int capacity, /* REC'D: Capacity of array */ double an_array[], /* P'BACK: Array to be filled */ int *count) /* P'BACK: # of elements stored */ { double value;
/* Initialize count */ *count = 0;
/* Read in first value */ printf ("Enter a number (negative to end input): "); scanf ("%lf", &value);
/* Repeat while not a negative value and array not full */ while (value >= 0 && *count < capacity) { /* Store value in array */ an_array[*count] = value;
/* Count the value */ (*count)++;
/* Read next value */ printf ("Enter a number (negative to end input): "); scanf ("%lf", &value); } /* end while */ } /* end read_numbers */
/* Function: print_integers - prints out the elements of an array * NUM_IN_LINE on a line */ void print_numbers (const double an_array[], /* REC'D: Array to be printed */ int num_elements) /* REC'D: # of elements stored */ { int i;
printf ("The values entered are: "); /* For each element indexed by i */ for (i = 0; i < num_elements; i++) { /* 1.1 Display the element */ if (i % NUM_IN_LINE == 0) printf(" "); printf ("%7.2lf", an_array[i]); } /* end for each element */ printf (" "); } /* end print_numbers */ * Assignment: Practical Exam 2 Retake, Problem 2 Date: April 29, 2015 * Programmer: <fill in your name)> */
#include <stdio.h> #include <stdlib.h>
#define NUM_IN_LINE 5
/* Function prototypes */ void read_numbers (int capacity, double an_array[], int *count); void print_numbers (const double an_array[], int num_elements);
int main () {
return 0; } /* end main */
/* FUNCTION compute_array_average CODE GOES HERE * ----------------------------------- */
/* FUNCTION compute_array_deviation CODE GOES HERE * ----------------------------------- */
/* Function: read_numbers - reads values from keyboard until a negative number * and stores them in an array up to capacity */ void read_numbers (int capacity, /* REC'D: Capacity of array */ double an_array[], /* P'BACK: Array to be filled */ int *count) /* P'BACK: # of elements stored */ { double value;
/* Initialize count */ *count = 0;
/* Read in first value */ printf ("Enter a number (negative to end input): "); scanf ("%lf", &value);
/* Repeat while not a negative value and array not full */ while (value >= 0 && *count < capacity) { /* Store value in array */ an_array[*count] = value;
/* Count the value */ (*count)++;
/* Read next value */ printf ("Enter a number (negative to end input): "); scanf ("%lf", &value); } /* end while */ } /* end read_numbers */
/* Function: print_integers - prints out the elements of an array * NUM_IN_LINE on a line */ void print_numbers (const double an_array[], /* REC'D: Array to be printed */ int num_elements) /* REC'D: # of elements stored */ { int i;
printf ("The values entered are: "); /* For each element indexed by i */ for (i = 0; i < num_elements; i++) { /* 1.1 Display the element */ if (i % NUM_IN_LINE == 0) printf(" "); printf ("%7.2lf", an_array[i]); } /* end for each element */ printf (" "); } /* end print_numbers */
TMOXDEPY THIESE PUNCTIONS nnst one eeet in the seras. Please write your code for this h) Write a fuaction compete.array.deriatson that anray ia the seray It st se the banction cospute.AFEAY AVEE ge Meary. Please write your code th1·function In tspace indic (e) WrRe·main program that ded m-array of 50 uss print.umbers to daplay the valaos in the ang, and displays the stsdaed devlation of te aln in the array comiputed by conpate array deviation s read.auabers to Sill the array, The outpat might look somwthing like ater a suaber (oegative to end isput): 12 Enter a sunber (negatsve to end iaput): 24 Enter a sunber (negative to end isput): 33 Enter a sunber (egative to esd inpat): 47 Enter a sunber (negative to end iapat): ss Enter a susber (aegative to ead inpat): 60 Iater a suaber (segative to end isput): - The values estered are 12.00 24.00 33.00 47.00 56.00 60.00 The standard deviation at these ralses is: us.n The program must be implemeuted using the read susbers, priat ers conpute.array deviation fanctions to earn full credit When you have completed this peoblem, make sure you have pat your e in the s co ock, ip up the Sle problen2rt.c and sabmit it as usual ander aigme 25-PECOt March 31, 2015
Explanation / Answer
The code is rightcheck for the syntactical errors.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.