Sum of array elements using pointers
C++
Easy
pointers
Task «Sum of array elements using pointers»
Write a program that reads the size of an array and its elements, and then calculates the sum of all elements using pointers. Use pointer arithmetic to access the array elements.
Input Format
In the first line, an integer N (1 ≤ N ≤ 100). In the second line, N integers (each not exceeding 1000 in absolute value).
Output Format
One integer — the sum of the array elements.
Examples
Example 1
INPUT
5
1 2 3 4 5
OUTPUT
15
Example 2
INPUT
3
-1 -2 -3
OUTPUT
-6
Example 3
INPUT
1 10
OUTPUT
10
Example 4
INPUT
5 3
OUTPUT
3
main.cpp