← Back to Arrays
Question 295
Sum of Even-Indexed Elements
Sum of Even-Indexed Elements
You are given an array of integers. Add up only the elements that sit at even index positions (index 0, 2, 4, and so on), ignoring the ones at odd indices. Because you need the index number itself, use a for loop with a counter rather than a foreach. Print the resulting sum.
Expected Output:
9= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
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 (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.