Skip to content

Instantly share code, notes, and snippets.

@sifue
Created August 25, 2018 02:27
Show Gist options
  • Save sifue/ba14cb05038cda8f8074180c0fe111d3 to your computer and use it in GitHub Desktop.
Save sifue/ba14cb05038cda8f8074180c0fe111d3 to your computer and use it in GitHub Desktop.
average.cpp
#include <iostream>
using namespace std;
double average(int AVR[], int N) {
double sum = 0;
for (int i = 0; i < N; i++) {
sum += AVR[i];
}
double answer = sum / N;
return answer;
}
int main() {
int AVR[6] = {1, 2, 3, 4, 5, 6};
cout << average(AVR, 6) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment