Write a loop that reads positive integers from console input and that terminates when it reads an integer that is not positive. After the loop terminates, it prints out the sum of all the even integers read.

PHOTO EMBED

Fri Sep 22 2023 21:16:18 GMT+0000 (Coordinated Universal Time)

Saved by @David_Mix

int x;
int sum = 0;
cin >> x;
while (x > 0) 
{
  if (x % 2 == 0)
    sum += x;
  cin >> x;
}
cout << sum;
content_copyCOPY