#include <stdio.h> int sum_even_numbers(int *ptr, int n) { int sum=0; while(n>0) { if(*ptr % 2 == 0) { sum+=*ptr; } ptr++; n--; } return sum; } int main() { int n; scanf("%d", &n); int arr[100]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } int result = sum_even_numbers(arr, n); printf("Sum = %d", result); return 0; }
Test Cases
Test Results
Input
5 10 21 32 43 50
Expected Output
Sum = 92