chillurbrain

Task5_7_2

Dec 21st, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. double getAverage(int* arr, int size)
  8. {
  9.     double answer = 0.0;
  10.     for(int i = 0; i < size; i++)
  11.         answer += arr[i];
  12.     return answer / size;
  13. }
  14.  
  15. int main()
  16. {
  17.     const int SIZE = 5;
  18.     int array[SIZE];
  19.     for(int i = 0; i < 5; i++)
  20.         cin >> array[i];
  21.     cout << getAverage(array, SIZE);
  22.     _getch();
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment