To check whether an integer is even or odd, the remainder is calculated when it is divided by 2 using modulus operator ‘%‘. If remainder is zero, Then that integer is even if not that integer is odd.
Let’s write a program which print Even or odd numbers in C++.
Step 1: Let’s open turboC++ and write the following Code .
// Add preprocessor
long int a;
cout<<”this is an even number:”;
cout<<”this is an odd number:”;
Step 2: Run the program and see output: