Skip to content

Commit

Permalink
Resolved issue smuos#2, mean function working.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsl94 committed Sep 25, 2014
1 parent 819add5 commit 31d38fb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@

#define debug 0

//Mean calculating function
double mean(int *pt, int length)
{
int sum = 0;
double mean = 0;
for(int i = 0; i < length; i++)
{
sum = sum + pt[i];
}
mean = ((double)sum/length);
return mean;
}

// Comparison function for qsort()
int numcmp (const void *a, const void *b) {
int x = *((int*) a);
Expand Down Expand Up @@ -48,5 +61,7 @@ int main(int argc, char *argv[]) {
}
fprintf(stdout, "\n%s: FIN. \n", argv[0]);

// Call mean function
fprintf(stdout, "The mean is: %.2f \n", mean(pt, length));
return 0;
}

0 comments on commit 31d38fb

Please sign in to comment.