Tuesday, 9 July 2013

Even and Odd number test in C++

#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int x;
    cout<<"Enter any number : ";
    cin>>x;

    if ( x % 2 == 0 )
    cout<<endl<<x<<" is Even number"; //Remember 0 is an even number
    else
    cout<<endl<<x<<" is Odd number";
    getch();
}

No comments:

Post a Comment