Answers for "c++ program to check even or odd using functions"

C++
0

c++ check if number is even or odd

#include <iostream>
using namespace std;
int main() {
   int num = 7;
   if((num & 1) == 0)
   cout<<num<<" is even";
   else
   cout<<num<<" is odd";
   return 0;
}
Posted by: Guest on August-03-2021
0

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;
}
Posted by: Guest on February-01-2022

Code answers related to "c++ program to check even or odd using functions"

Browse Popular Code Answers by Language