Even or Odd

    0

    0

    Giovanny Gongora

    Codiga's C++ Recipes

    Check if the given number is Even or Odd Using ternary or conditional Operator

    #include <iostream>
    
    using namespace std;
    int evenOrOdd() {
      int number;
      cout << "Enter any number : ";
      cin >> number;
      (number % 2 == 0) ? cout<<"Even number" : cout<<"Odd number";
      return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.