Skip to content

Instantly share code, notes, and snippets.

@sifue
Created August 25, 2018 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sifue/1d792621a6899df876db238753279174 to your computer and use it in GitHub Desktop.
Save sifue/1d792621a6899df876db238753279174 to your computer and use it in GitHub Desktop.
average2.cpp
#include <iostream>
#include <vector>
using namespace std;
double average(vector<int> AVR) {
double sum = 0;
int length = AVR.size();
for (int i = 0; i < length; i++) {
sum += AVR[i];
}
double answer = sum / length;
return answer;
}
int main() {
vector<int> AVR = {1, 2, 3, 4, 5, 6};
cout << average(AVR) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment