Write a program in C++ and python to check whether the number is even or odd

By | October 4, 2021
Write a program in C++ and python to check whether the number is even or odd

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++:

Vamware
#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

People are also reading:

Leave a Reply

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