Friday, 7 November 2014

Write a C++ program to check whether the given number is even or odd (using ? : ternary operator )

#include<iostream>

int main()

{

int a;

cout<<"Enter a Number : ";

cin>>a;

(a%2==0)?cout<<"Number is even":cout<<"Number is odd";

cin.ignore();

cin.get();

return 0;

}

No comments:

Post a Comment