Check even or odd

Description:

Write a program to check whether the given number is even or odd (using ? : ternary operator ) Test Case 1 Input (stdin) 5 Expected Output Number is odd Test Case 2 Input (stdin) 2 Expected Output Number is even

Program :


#include <iostream>

using namespace std;

int main()

{

int a;

  cin>>a;

  if(a%2==0)

    cout<<"Number is even";

  else

    cout<<"Number is odd";

return 0;

}