chillurbrain

Task4_7_2

Dec 21st, 2015
60
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 <conio.h>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int sumRange(int *start, int *end)
  8. {
  9.     int answer = 0;
  10.     while(start != end)
  11.     {
  12.         answer += *start;
  13.         start++;
  14.     }
  15.     return answer;
  16. }
  17.  
  18. int main()
  19. {
  20.     const int SIZE = 5;
  21.     int array[SIZE];
  22.     for(int i = 0; i < 5; i++)
  23.         cin >> array[i];
  24.     cout << sumRange(array, array + SIZE);
  25.     _getch();
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment