I’ve been reading up on the differences between C and C++, and I came across this interesting article on the Difference between C and C++.
I took this question from distinctions between C and C++. Here’s a problem:
Problem Statement:
Given an array of integers, write a program in either C or C++ to find and print the sum of all the elements in the array.
Input:
- The first line of input contains an integer ‘N’, denoting the number of elements in the array.
- The second line contains ‘N’ space-separated integers, representing the elements of the array.
Output:
Print the sum of all elements of the array.
**Constraints:**
- 1 ≤ N ≤ 10^5
- -10^9 ≤ Array elements ≤ 10^9
Help me with the answer.
Thank you.