C++ Program To Find Whether The Number is Even or Odd

Even Numbers : Any digit or number which can be divided by 2 or groups of 2 are called as even numbers. 
Numbers like 0 , 2 , 4 , 6 , 8 , 10 , 12 , 16 ...

Odd Numbers   : Numbers other than even numbers are called as odd numbers.
Numbers like 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 ...

Algorithm:
Need to check which numbers are divided by 2.

Program code:
#include<iostream>
#include<conio.h>
using namespace std;

int main()
{

  int number;
  char redo;
  
  cout<<"*************************************"<<endl;
  cout<<"           Even or Odd               "<<endl;
  cout<<"*************************************"<<endl<<endl;

 do
 {

    cout<<"Enter any Number  =  ";
    cin>>number;
    cout<<endl<<endl;
    
  
    if(number%2==0)
    cout<<number <<"  =  Even Number "<<endl<<endl;
  
    else
    cout<<number<< "  =  Odd  Number "<<endl<<endl;
    
    cout<<"*************************************"<<endl<<endl;
    
    cout<<"Enter y or Y for next number  =  ";
    cin>>redo;
    cout<<endl<<endl;


  }while(redo == 'y' || redo == 'Y' );

   getch();
}


Output: After compile and run ,, the output will be like this

Click on pic to enlarge it.

Hope that you will find this helpful.


No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.