1. Engineering
2. Computer Science
3. statement write a complete modular and properly documented c program...

# Question: statement write a complete modular and properly documented c program...

###### Question details

Statement: Write a complete, modular, and properly documented C program. Given a data set of integers of some given size (say N), the program will find/compute: (a) position of the largest value, (b) position of the smallest value, and (c) integer average value.

The data set and the results obtained will be printed on standard output using library function printf(). All output printed must have an appropriate caption with integer values printed in 10 columns (right justified). For the data set values print 6 values per line of output.

Modules needed:

1. int main(); /* of course */ 2. int maxpos(int d[], int low, int high); /* d[maxpos] is the largest value in the unordered data set low <= maxpos <= high */

3. int minpos(int d[], int low, int high); /* d[minpos] is the smallest value in the unordered data set low <= minpos <= high */

4. int average(int d[], int size); /* caution it is integer average */

5. void selectsort(int d[], int size); /* orders the data in data set in ascending order using selection sort by calling minpos() and is called by median() only */

6. int median(int d[], int size); /* half of the values are smaller than the median and half of the values are greater than the median, calls selectsort() for sorting the data set */

7. void printdata(int d[], int size); /* print 6 values per line of output with each value printed in 10 columns */

8. void printresults(int largest, int smallest, int average, int medianval);

1. do not use return 0 at the end of main(), use exit(0) instead.

2. int next = 234; printf("%6d ", next); will print value of next, right justified in 6 columns

#include <stdio.h>

#include <stdlib.h>

#define SIZE 22

int main()

{

int data[SIZE] = {1, 2, 3, -3, -99, 999, 42, 14, 56, 76, 99, 12, -2345, 3456789, 199, 123, 234, -567, -999, 21, 32, -12345}; int size;

int mxpos;

/* Other declarations, as needed go here..*/

size = SIZE;

if (size > 0)

{ /* Call your modules as needed, test one module at a time, for example:

mxpos = maxpos(data, 0, size-1); */ }

exit(0);

}

Sample output:

Largest value: xxxx

Smallest value: yyyy

Average Value: aaaa

Median value: mmmm

###### Solution by an expert tutor 