Post Top Ad

Sunday, January 20, 2019

C++ Program to Check the Integer is Odd or Even


In order to solve this problem, you need to understand about IF-ELSE.

what is even number? The even number is the integer number which is divided by 2.







C++ Program:

#include <iostream>
using namespace std;

int main()
{
    int n;

    cout << "Enter an integer: ";
    cin >> n;

    if ( n % 2 == 0)
        cout << n << " is even.";
    else
        cout << n << " is odd.";

    return 0;
}

No comments:

Post a Comment