Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

check if a number is even or odd C++

// @Author: Subodh 
// 1 liner solution
(num & 1) ? cout << num << " is odd" : cout << num << " is even" << endl;
Comment

check even or odd c++

#include<iostream>
using namespace std;

int main()
{
  int num1 , num2;   // Declaration of two variables
  cout<<"Please enter the first number: ";
  cin>>num1;  // Taking the first number as input

  cout<<"Please enter the second number: ";
  cin>>num2;   // Taking the second number as input

  if(num1 % 2 == 0)  // if the remainder is zero so the number is divisible by 2 and it is an even number
    cout<<"The first number is Even
";
  else    // if the remainder is not equal 2 so the number is not divisible by 2 and it is an odd number
    cout<<"The first number is Odd
";

  if(num2 % 2 == 0)
    cout<<"The second number is Even
";
  else
    cout<<"The second number is Odd
";

  return 0;
}
Comment

how to find even and odd numbers in c++

#include<bits/stdc++.h>
using namespace std;

int main ()

{
    int x;
    cin >> x;
    if (x % 2 == 0) {
        cout << x << " " <<"is even number" endl;
    } else {
        cout << x << " " << "is odd number" endl;
        }

    return 0;
}
Comment

even and odd in c++

#include <iostream>
using namespace std;

int main()
{
	int n;
	cout << "Enter an integer: ";
	cin >> n;
	(n % 2 == 0) ? cout << n << " Is Even." : cout << n << " Is Odd.";
}
Comment

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;
}
Comment

even or odd program in c++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int inp;
  cin>>inp;
  if(inp % 2 == 0)
  {
    cout<<" Even" <<endl;
  }
  else
  {
    cout<<"Odd"<<endl;
  }
}		
Comment

even odd c++

#include <iostream>
using namespace std;

int main()		{
	int x;
	cout << "Enter a number:";
	cin >> x;
		if (x%2==0)
		 	{
				cout <<x<<" is an EVEN number.";
			}
		else
			{
				cout <<x<<" is an ODD number.";
			}
	return 0;
				}
Comment

PREVIOUS NEXT
Code Example
Cpp :: vector insert to end 
Cpp :: wgat is duble in c++ 
Cpp :: 41.00 
Cpp :: lap trinh file explorer c++ 
Cpp :: unambiguous 
Cpp :: c++ file handiling 
Cpp :: uint16_t in c++ 
Cpp :: Bit Tricks for Competitive Programming c ++ 
Cpp :: c++ get microseconds since epoch 
Cpp :: cplusplusbtutotrail 
Cpp :: void setup() { // put your setup code here, to run once:in m}void loop() { // put your main code here, to run repeatedly:} 
Cpp :: the number of ones int bitset 
Cpp :: Summation of Natural Number Sequence with c and c++. 
Cpp :: function and function prototype. 
Cpp :: C++ Display a text 5 times 
Cpp :: linq select where string equals "String" 
Cpp :: convert datatype of field db browser from text to timedate db browser 
Cpp :: ue4 c++ enum variable declaration 
Cpp :: start google 
Cpp :: cin une énumération 
Cpp :: cpprestsdk header 
Cpp :: set the jth bit from 1 to 0 
Cpp :: set precision on floating numbers 
Cpp :: GCD(x, yz) 
Cpp :: can map return a value to a variable in c++ 
Cpp :: linked 
Cpp :: how to add 2 objects using operator overloading in c++ 
Cpp :: c++ program 
Cpp :: std::random_device 
Cpp :: c++ fps sleep while loop 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =