CJCoding With Joseph
15free / daySign inCreate account

Sum of Elements at Even Indices

An array called nums has already been created for you with the values {10, 20, 30, 40, 50}.

Your task is to add up only the elements that are at even index positions (indices 0, 2, and 4) and print the sum.

This is different from summing even numbers: here you are checking whether the index is even, not the value. The elements at even indices are:
- Index 0: 10
- Index 2: 30
- Index 4: 50

Their sum is 90.

Print the result in the exact format shown in Expected Output.

Expected Output:

Sum at even indices: 90

= newline. No newline after the last line.

Hints3 available
Topics:
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.