Q:

Write an expression to determine whether an int value is even or odd

0

Write an expression to determine whether an int value is even or odd.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>

int main() {
  int i;
  std::cin >> i;
  if (i % 2)
    std::cout << i << " is an odd number." << std::endl;
  else
    std::cout << i << " is an even number." << std::endl;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now