C++ examples for Data Type:int
Reads an integer and determines and prints whether it's odd or even.
#include <iostream> int main(int argc, const char *argv[]) { int num1;//from w w w . java 2 s.c om std::cout << "Enter an integer: "; std::cin >> num1; std::cout << num1 << " is " << ((num1 % 2 == 0) ? "even" : "odd") << std::endl; return 0; }