Commit 8cb16c0
committed
feat: Calculate sum of dynamic array elements entered by user
🧠 Logic:
- Takes input `n` from user to define array size.
- Initializes an array `A` of size `n`.
- Accepts `n` integer inputs from the user and stores them in the array.
- Prints each array element.
- Iterates through the array and calculates the sum of all elements.
- Displays the total sum.
Signed-off-by: Somesh diwan <[email protected]>1 parent be34c11 commit 8cb16c0
1 file changed
+6
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 3 | + | |
| 4 | + | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
18 | | - | |
19 | | - | |
| 15 | + | |
20 | 16 | | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
25 | | - | |
26 | | - | |
| 21 | + | |
27 | 22 | | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
31 | 26 | | |
32 | | - | |
33 | | - | |
| 27 | + | |
34 | 28 | | |
35 | 29 | | |
36 | 30 | | |
37 | 31 | | |
38 | | - | |
| 32 | + | |
0 commit comments