Skip to content

Instantly share code, notes, and snippets.

@6uclz1
Created October 26, 2015 14:27
Show Gist options
  • Save 6uclz1/89f0fd6d965c4e8f996c to your computer and use it in GitHub Desktop.
Save 6uclz1/89f0fd6d965c4e8f996c to your computer and use it in GitHub Desktop.
//mondai1
#include <stdio.h>
int ave(int[], int);
int main()
{
int num[5], i;
for(i = 0; i < 5; i++) {
printf("%s", "? ");
scanf("%d", &num[i]);
}
printf("Average: %d\n", ave(num, 5));
}
int ave(int num[], int n)
{
int i, sum = 0;
for(i = 0; i < n; i++) sum = sum + num[i];
return sum / n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment