Skip to content

Commit

Permalink
Added smuos#1 mean() function
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwentao committed Oct 1, 2014
1 parent b5d3856 commit 0ea92be
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@

#define debug 0



//Add mean function
float mean (int num[], int length)
{
//Initial sum = 0
float sum = 0;
float mean;

//for loop to add up sum
for (int i = 0; i < length; i++)
{
sum = sum + num[i];
}
mean = sum / length;
return mean;
}



// Comparison function for qsort()
int numcmp (const void *a, const void *b) {
int x = *((int*) a);
Expand Down

0 comments on commit 0ea92be

Please sign in to comment.