// Recapping 1D arrays! // Problem: A user is asked to enter 5 numbers. We will then go // through these numbers and find the sum of the odd numbers only. #include #define MAX 5 int main(void) { int sum_odd_nos = 0; // Declare an array to store the numbers that the user will enter int array[MAX]; for(int i = 0; i < MAX; i++) { printf("Please enter a number: "); scanf("%d", &array[i]); } for(int i = 0; i < MAX; i++) { if(array[i] % 2 == 1) { sum_odd_nos = sum_odd_nos + array[i]; } } printf("The sum of the odd numbers is %d\n", sum_odd_nos); return 0; }