Welcome to the World of Online Learning:
Hello Friends “This blog helps you to learn C++ programming concepts. You can learn C++ language at your own speed and time. One can learn concepts of C++ language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Write a program to check Whether Number is Even or Odd using if else
1. PROGRAM: C++ program to check Whether Number is Even or Odd using if else
/*C++ program to check Whether Number is Even or Odd using if else*/
#include <iostream>
using namespace std;
int main() {
int n;
cout << “Enter an integer: “;
cin >> n;
if ( n % 2 == 0)
cout << n << ” is even.”;
else
cout << n << ” is odd.”;
return 0;
}
2. PROGRAM: C++ program to check Whether Number is Even or Odd using ternary operator
/*C++ program to check Whether Number is Even or Odd using ternary operator */
#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.”;
return 0;
}