Answers for "c++ check if odd or even"

C++
1

c++ check if odd or even

#include <iostream>
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;
}
Posted by: Guest on August-03-2021

Browse Popular Code Answers by Language