Created
August 8, 2011 23:10
-
-
Save albert-chang0/1133005 to your computer and use it in GitHub Desktop.
Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
double avg(int[], int); | |
double avg(int nums[], int count) | |
{ | |
int i, sum = 0; | |
for (i = 0; i < count; ++i) | |
{ | |
sum += nums[i]; | |
} | |
return (double)sum / count; | |
} | |
int main(int argc, const char *argv[]) | |
{ | |
int i, nums[argc - 1]; | |
for (i = 1; i < argc; ++i) | |
nums[i - 1] = atoi(argv[i]); | |
printf("%f\n", avg(nums, argc - 1)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment