You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## This is a solution to HackerEarth problem. Following steps are followed:
4
+
5
+
- First, we take the size of the array as input (N).
6
+
7
+
- Then, the array is declared to be of integer type.
8
+
9
+
- The space separated array elements are taken as input from user.
10
+
11
+
- An integer type variable called *sum* is declared and initialised with value 0 as no array element is added yet.
12
+
13
+
- Now, a for loop is used to read each element starting from index 0 to N-1 and are simultaneously added to previous value of sum and array element present at that particular loop index.
14
+
15
+
- Lastly, the variable sum which contains the final answer is printed as the output.
16
+
17
+
### Find the link to the problem statement here: https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/array-sum-2-725368ac/
- First, we take the size of the array as input (N).
6
+
7
+
- Then, the array is declared to be of integer type.
8
+
9
+
- The space separated array elements are taken as input from user.
10
+
11
+
- An integer type variable called *sum* is declared and initialised with value 0 as no array element is added yet.
12
+
13
+
- Now, a for loop is used to read each element starting from index 0 to N-1 and are simultaneously added to previous value of sum and array element present at that particular loop index is added two times.
14
+
15
+
- Lastly, the variable sum which contains the final answer is printed as the output.
0 commit comments