#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;
}
#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;
}
#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.";
}
#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;
}
}
#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;
}
Code Example |
---|
Cpp :: string to integer in c++ |
Cpp :: c++ encapsulation |
Cpp :: cpp string slice |
Cpp :: c++ thread incide class |
Cpp :: c++ int to char* |
Cpp :: c++ logger class example |
Cpp :: remove specific element from vector c++ |
Cpp :: vector find |
Cpp :: how to declare a 2D vector in c++ of size m*n with value 0 |
Cpp :: cpp vs c# |
Cpp :: number of digits in int c++ |
Cpp :: Palindrome String solution in c++ |
Cpp :: What is the "--" operator in C/C++? |
Cpp :: cpp float |
Cpp :: setw c++ |
Cpp :: notepad++ |
Cpp :: convert integer to string in c++ |
Cpp :: How to get cursor position c++ |
Cpp :: C++ Infinite while loop |
Cpp :: how to say hello world in c++ |
Cpp :: SUMOFPROD2 |
Cpp :: c++ get whole line |
Cpp :: system("pause") note working c++ |
Cpp :: system cpp |
Cpp :: do while c++ |
Cpp :: CRED Coins codechef solution in c++ |
Cpp :: C++ fibo |
Cpp :: how to check if vector is ordered c++ |
Cpp :: c++ comment out multiple lines |
Cpp :: stoi in c++ |