Array processing

0 Christopher McLean · November 3, 2014
Write a program which prompts the user to enter the number of values to process 
(a maximum of 100). Next prompt, and allow the user to enter each of the 
values. Store these values in an array. Print the largest value, the smallest 
value, and the average (to 2 decimal places) of the values in the array. You must 
use functions for each of these tasks. The GetValues() function is the only 
function that may change the array.

The prototypes for the functions must be:
void GetValues(int x[], int *pN);
int FindBig(int x[], int n);
int FindSml(int x[], int n);
float FindAvg(int x[], int n);

GetValues should put values in both the x[] array and at *pN
FindBig should return the largest integer in the first n elements of x[]
FindSml should return the smallest integer in the first n elements of x[]
FindAvg should return the average of the first n elements of x[]
Thus, the main program should exactly something like the following:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
// prototypes as listed above
void main()
{
int a[100], myBig, mySml, n;
float myAvg;
GetValues(a,&n);
myBig=FindBig(a,n);
mySml=FindSml(a,n);
myAvg=FindAvg(a,n);
printf("The largest value is: %d\n",myBig);
printf("The smallest value is: %d\n",mySml);
printf("The average value is: %.2f\n",myAvg);
}

Post a Reply

Replies

Oldest  Newest  Rating
-1 Youknees Adoro · November 4, 2014
have you tried building the codes? If yes, please post it here
  • 1

C

107,124 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator