509,144 views
14 votes
14 votes
How would i do this?

Create a program that will do the following
• Ask the user to enter an unknown set of integers, and stop when they enter 9999
• Add up all the even numbers.
• After the loop, print the sum of the even numbers with a label

User Lalo
by
3.3k points

1 Answer

18 votes
18 votes

Answer:

#include <iostream>

using namespace std;

int main() {

int num = 0, sum = 0;

do {

cin >> num;

if (num % 2 == 0) {

sum += num;

}

} while (num != 9999);

cout << "The sum of the even numbers is " << sum;

}

User Brandon Linton
by
2.8k points