39: Write a ternary program to show that a number is even or odd
// Write a ternary program to show that a number is even or odd
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "Enter a number: ";
cin >> num;
num % 2 == 0 ? cout << "This is an even number" : cout << "This is an odd number";
return 0;
}
Comments
Post a Comment