Question: Write a C program to input n numbers in an array, calculate the sum of all even numbers and all odd numbers in the array

Write a C program to input n numbers in an array, calculate the sum of all even numbers and all odd numbers in the array and print the larger sum. [15 marks]
Example:
If the array contains the following elements: 2,3,3,5,4,8,7,11,2
The sum of all even elements is 2+4+8+2=16
Sum of all odd elements is 3+3+5+7+11=29 Therefore, the output should be 29

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!