Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

even and odd sum in c++

#include<iostream>
using namespace std;

int main()
{
	do
	{
		int num, even = 0, odd = 0;

		for (int i = 0; i < 8; i++)
		{
			cin >> num;
			if (num % 2 == 0)
				even += num;
			else
				odd += num;
		}

		cout << "Even: " << even << endl;
		cout << "Odd: " << odd << endl;

	} while (true);
	

	return 0;
}
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #odd #sum
ADD COMMENT
Topic
Name
6+5 =