From 5721564e8babae83d72a1018151f26b2af2cb466 Mon Sep 17 00:00:00 2001 From: Durgesh kumar prajapati <98798977+Durgesh4993@users.noreply.github.com> Date: Tue, 11 Oct 2022 13:38:20 +0530 Subject: [PATCH] Create Even or Odd using ternary in cpp operators --- Even or Odd using ternary in cpp operators | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Even or Odd using ternary in cpp operators diff --git a/Even or Odd using ternary in cpp operators b/Even or Odd using ternary in cpp operators new file mode 100644 index 0000000..e1912a4 --- /dev/null +++ b/Even or Odd using ternary in cpp operators @@ -0,0 +1,13 @@ +#include +using namespace std; + +int main() { + int n; + + cout << "Enter an integer: "; + cin >> n; + + (n % 2 == 0) ? cout << n << " is even." : cout << n << " is odd."; + + return 0; +}