This tutorial will help you write a program in C, C++, Python, and Java to check whether a user-entered number is even or odd.
To write this program, you must know the programming language syntax and the if...else statement.
So, let us get started!
What is an Even and Odd Number?
Odd Number: Any natural number expressed in the form of (2n+1), where n is a natural number, is an odd number. In other words, it is a number not divisible by 2.
Examples of odd numbers include 1, 3, 5, 7, 9, etc.
Even Number: Any natural number expressed in the form of 2n, where n is a natural number, is an even number. In other words, it is a number completely divisible by 2.
Examples of even numbers include 2, 4, 6, 8, etc.
C Program to Check Whether the Number is Even or Odd
Output
C++ Program to Check Whether the Number is Even or Odd
Output
Python Program to Check Whether the Number is Even or Odd
Output
Java Program to Check Whether the Number is Even or Odd
Output
Conclusion
You might have found it easy to write a program in C, C++, Python, and Java to check whether a number is even or odd. It is an entry-level program where individuals implement to learn a specific programming language.
If you face any difficulties, do let us know in the comments. We would be glad to help you.
People are also reading:
- Python Examples
- Python RegEx
- How many Centimeters in a Foot through Python?
- Rectangle & Pyramids Pattern in C++
- C Program to Convert Feet into Inches
- C Program to Extract a Portion of String
- C++ and Python Code to Find The Sum of Elements Above and Below The Main Diagonal of a Matrix
- Linear Search in Python and C++
- Binary Search in C
- Perfect Number in C
Leave a Comment on this Post