In this program, we will code to check whether the entered number is an even or odd. An even number is that number which is divisible by 2 and an odd number is that number which is not divisible by 2.

C++:

#include<iostream.h>
#include< conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int num;
cout<<"Enter a number: ";
cin>>num;
if(num%2==0)
cout<<"It is an even number";
else
cout<<"It is an odd number";
getch();
}

Output:

Enter a number: 24
It is an even number

Python:

num=int(input("Enter a number: "))
if num%2==0:
    print("It is an even number")
else:
    print("It is an odd number")

Output:

Enter a number: 123
It is an odd number

Leave a Reply

Your email address will not be published. Required fields are marked *