# WAP in C to create a matrix age[20] to store any twenty ages and print the sum of all even and odd ages respectively

The program in c to create a matrix age[20] to store any twenty ages and print the sum of all even and odd ages respectively is given below:

``````#include <stdio.h>

int main() {
int age[20], i, even_sum = 0, odd_sum = 0;

printf("Enter 20 ages: \n");
for (i = 0; i < 20; i++) {
scanf("%d", &age[i]);
}

for (i = 0; i < 20; i++) {
if (age[i] % 2 == 0) {
even_sum += age[i];
} else {
odd_sum += age[i];
}
}

printf("Sum of even ages: %d\n", even_sum);
printf("Sum of odd ages: %d\n", odd_sum);

return 0;
}
``````

## Output:

Enter 20 ages:
1
2
3
4
5
6
7
8
9
10
19
18
17
16
15
14
13
12
11
20
Sum of even ages: 110
Sum of odd ages: 100

## Pro-Tips💡

This program uses a for loop to read in 20 ages from the user, and another for loop to calculate the sum of even and odd ages.

The program then prints out the sums.

### Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

### Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

### Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

## C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

## C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

## C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

## C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

## C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

## C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X