A C++ Program To Determine Whether A Number’s Input Is Even Or Odd

An even number is any integer that divides by two equally. When I say a number is evenly divisible, I mean that when we divide it by 2, there is no residue. For instance, even numbers include 2, 4, 6, 8, etc.
Odd numbers are integers that leave a remainder when divided by two. For instance, the numbers 3, 5, 7, and 9 are odd.

Create a program to verify even odd numbers.

Program to determine whether the entered integer is even or odd, for instance

You need be familiar with C++’s if-else statements and user-defined functions in order to comprehend this application.

#include <iostream>
using namespace std;
bool checkEvenOdd(int num);

int main(){
   int num;
   bool isEven;
   cout<<"Enter any number: ";
   //Storing the entered value in variable num
   //Calling the function that checks even odd
   isEven = checkEvenOdd(num); 
      cout<<num<<" is an even number"; 
      cout<<num<<" is an odd number";
   return 0;
/* This function checks whether the passed number is even
 * or odd. If the number is even then this function returns
 * true else it returns false.
bool checkEvenOdd(int num){
   bool b;
   /* If number is perfectly divisible by 2 then it is
    * an even number else it is an odd number
   if (num % 2 == 0)

   return b;


Enter any number: 101
101 is an odd number


Related Articles

Leave a Reply

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

Back to top button