Created
August 25, 2018 02:35
-
-
Save sifue/1d792621a6899df876db238753279174 to your computer and use it in GitHub Desktop.
average2.cpp
This file contains 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 <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