Can Anyone Help Me Figure Out What I'm Doing Wrong. If you cost post the correction or and example I would appreciate it greatly. I have posted all the criteria to the assignment below.
Assignment
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[]
A sample run is shown below (user input underlined). Note that user is prompted
for value 1, 2, 3, ... as opposed to 0, 1, 2, ... .
Enter number of integer values: 5
Enter value 1: 20
Enter value 2: -15
Enter value 3: 90
Enter value 4: 2
Enter value 5: 30
The largest value is: 90
The smallest value is: -15
The average value is: 25.40
Code:
Errors:Code:#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> void GetValues(int x[i], int *pN); int FindBig(int x[], int n); int FindSml(int x[], int n); float FindAvg(int x[], int n); int *pN; int size; int sum; 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); void GetValues(int x[i], int *pN); { int *pN; int size; int sum; int i; // Get user input for number of values here. printf("Enter Number Of Values: "); scanf("%d", size); // insure it is less than 100 for(size=1; size<=100; size++) { printf("Enter Value: "); scanf("d",size); { mySml = x[0]; myBig = x[0]; if(x[i]>myBig); { myBig = x[i]; return myBig; } if(x[i]<mySml); { mySml = x[i]; return mySml; } } sum = 0; { sum+=x[]; myAvg=(float)((float)sum/size); return myAvg; } } } }
Error 1 error C2065: 'x' : undeclared identifier 38 1 bigsml
Error 2 error C2059: syntax error : ']'
Error 3 error C2143: syntax error : missing ';' before '{' l
Error 4 error C2065: 'x' : undeclared identifier
Error 5 error C2059: syntax error : ']'
Error 6 error C2562: 'main' : 'void' function returning a value
Error 7 error C2065: 'x' : undeclared identifier
Error 8 error C2059: syntax error : ']'
Error 9 error C2065: 'x' : undeclared identifier
Error 10 error C2059: syntax error : ']'
Error 11 error C2562: 'main' : 'void' function returning a value
Error 12 error C2065: 'x' : undeclared identifier
Error 13 error C2059: syntax error : ']'
Error 14 error C2562: 'main' : 'void' function returning a value
Error 15 error C2059: syntax error : '}'
Error 16 error C2143: syntax error : missing ';' before '}'
Error 17 error C2059: syntax error : '}'