Q. 89. Using C++ Ternary Operator, input a number and check if its Even or Odd.
Copy Code:
#include <iostream>
using namespace std;
int main()
{
int a ;
cout << "Enter a number ";
cin >> a;
cout << (a%2==0 ? "EVEN" : "ODD");
return 0;
}
No comments:
Post a Comment