Website Summary Files Commits Branches @commit @diff @stats
path: root / Week07 / Exercise03.cpp
diff options
context:
space:
mode:
1 files changed, 22 insertions, 0 deletions
-rw-r--r--Week07/Exercise03.cpp22
diff --git a/Week07/Exercise03.cpp b/Week07/Exercise03.cpp
new file mode 100644
index 0000000..71342d9
--- /dev/null
+++ b/Week07/Exercise03.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+
+const unsigned int SIZE = 15;
+
+double average(int numbers[SIZE]) {
+ double sum = 0;
+
+ for (unsigned int i = 0; i < SIZE; i++)
+ sum += numbers[i];
+
+ return sum / SIZE;
+}
+
+int main() {
+ int input[SIZE];
+ for (unsigned int i = 0; i < SIZE; i++)
+ std::cin >> input[i];
+
+ std::cout << average(input) << std::endl;
+
+ return 0;
+}