Skip to content

Commit

Permalink
resolved smuos#2 added a function mean() to mm.c
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsmith414 committed Sep 25, 2014
1 parent 3f6b28a commit 46f60dc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mm.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// mm.c

/*
A simple C program to calculate the mean and median
of input numbers.
*/

#include <stdlib.h>
#include <stdio.h>

Expand All @@ -12,6 +19,16 @@ int numcmp (const void *a, const void *b) {
return 0;
}

// Function to calculate the mean
double mean (int *num, int length) {
float sum = 0;
for (int i=0; i<length; i++)
{
sum += num[i];
}
return sum / length;
}

int main(int argc, char *argv[]) {

int i, length, *pt;
Expand Down

0 comments on commit 46f60dc

Please sign in to comment.