Write a program to find whether the input number is an even or odd number.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<"Enter a number:";
cin>>a;
if((a!=0)&&((a%2) == 0))
{
cout<<"Even number";
}
else
{
cout<<"Odd number or the number is Zero";
}
getch();
}
OUTPUT:
Enter a number: 4
Even number
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<"Enter a number:";
cin>>a;
if((a!=0)&&((a%2) == 0))
{
cout<<"Even number";
}
else
{
cout<<"Odd number or the number is Zero";
}
getch();
}
OUTPUT:
Enter a number: 4
Even number
No comments:
Post a Comment