Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double Function(int *pArray, int numElements );
- int main( void )
- {
- // declare and initialize Array
- int Array[] = {78, 90, 56, 99, 88, 68, 92};
- // set number of elements in array
- int sizeofArray = sizeof(Array)/sizeof(int);
- // Set Avg
- double average = Function( Array, sizeofArray );
- //Print out Avg
- printf("The resulting average is %lf \n", average);
- int ch;
- while( (ch = getchar()) != EOF && '\n' != ch );
- getchar();
- }
- double Function(int *pArray, int numInts )
- {
- int sum = 0;
- double average;
- for(int i=0; i<numInts; i++)
- {
- sum += pArray[i];
- }
- average = (double)sum / numInts;
- return average;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement