sumpairs

Complete the program to output the sum of the:

  1. First and last
  2. Second and second to last
  3. Thirs and third to last
  4. ...

So if the array is: 9 8 4 5 6 2 your program should output:

11
14
9

You may assume the size of the array is even.

22
 
1
#include <iostream>
2
#include <string>
3
using namespace std;
4
5
int main() 
6
{
7
   int n;
8
   
9
   // biggest possible
10
   int arr[20];
11
   cin >> n;
12
   
13
   for(int i=0; i < n; i++){
14
     cin >> arr[i];  
15
   }
16
17
18
19
20
21
   return 0;
22
}