C++ Exercises: Calculate the sum of all even and odd numbers in an array
Sum of Even and Odd Numbers
Write a C++ program to calculate the sum of all even and odd numbers in an array.
Sample Solution:
C++ Code :
Sample Output:
Original array: 1 2 3 4 5 6 7 8 Sum of all even and odd numbers: 20,16
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C++ program to compute the sum of even and odd numbers in an array and then print both totals in a formatted manner.
- Write a C++ program that segregates even and odd numbers from an array, calculates their sums, and displays the results side by side.
- Write a C++ program to read an array of integers, sum the even and odd numbers separately, and then output the difference between the sums.
- Write a C++ program that computes the sum of even and odd numbers in a dynamically allocated array and prints the results with labels.
C++ Code Editor:
Previous: Write a program in C++ to calculate the volume of a cylinder.
Next: Write a program in C++ which swap the values of two variables not using third variable.
What is the difficulty level of this exercise?