Write a program to check whether the given number is even or odd (using ? : ternary operator )
Source Code
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter the Number : ";
cin>>a;
(a%2==0)?cout<<"Number is even":cout<<"Number is odd";
return 0;
}
Output
SAMPLE RUN # 1 Enter the Number : 56 Number is even SAMPLE RUN # 2 Enter the Number : 43 Number is odd