Write a program that will get the sum of even indexed elements and the sum of odd indexed elements?

In order to write a program, we have to have an algorithm. In this case, we can use two temporary variables to store up the sums:

evenSum = 0

oddSum = 0

for i = 0 to array.size do:

if isEven(i):
evenSum = evenSum + array[i]

else:

oddSum = oddSum + array[i]

Improve Answer Discuss the question "Write a program that will get the sum of even indexed elements and the sum of odd indexed elements?" Watch Question

First answer by Avir. Last edit by Avir. Contributor trust: 56 [recommend contributor]. Question popularity: 9 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Programming > Write a program that will get the sum of even indexed elements and the sum of odd indexed elements?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
The meaning of indexed allocation?  C program to find sum of elements in an array?  The sum of the elements divided by the number of elements?  1 Write a program to find the sum of the series S 1 x x2 ... xn?  Write a c program to find the sum of the given series 1 3 5 7 .?  What is the sum of the elements divided by the number of elements?  The averagethe sum of the elements divided by the nmber of elements?  The average the sum of the elements divided by the numbers of elements?  What is the averagethe sum of the elements divided by the number of elements?  Create a flowchart that will compute the sum of five numbersif sum is even display even otherwise odd?  What is the average the sum of the elements divided by the number of elements call in math?