Monday, 12 January 2015

Cpp Program to find whether a number is even or odd

This is a basic Cpp program which checks whether the given number is even or odd.

Generally if a number is divisible by 2 then we call that number as an even number else it is an odd number.For checking whether a number is divisible by 2 we find the remainder of the given number when divided by 2.If the remainder is 0 we say that the number is EVEN else it is ODD.

#include <iostream>

using namespace std;

int main()
    int n;
    cout << "Enter any number : \t" ;
    cin  >> n ;

    if(n%2 == 0)
        cout  << n << " is EVEN number " << endl;
        cout << n << " is ODD number " << endl;

    return 0;

Cpp - Even Or Odd

No comments:

Post a Comment