Advertisement
Spocoman

03. Sum Even Numbers

Nov 17th, 2023
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     const int MAX_SIZE = 99;
  7.     int numbers[MAX_SIZE]{};
  8.    
  9.     int arrSize, sumEven = 0;
  10.     cin >> arrSize;
  11.  
  12.     for (int i = 0; i < arrSize; i++) {
  13.         cin >> numbers[i];
  14.     }
  15.  
  16.     for (int i = 0; i < arrSize; i++) {
  17.         if (numbers[i] % 2 == 0) {
  18.             sumEven += numbers[i];
  19.         }
  20.     }
  21.  
  22.     cout << sumEven << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement