9 Aug 2019

  • August 09, 2019
  • Amitraj









// c++  program to check given no. is odd or even using class    By Amit raj purohit

http://codevidyalay.blogspot.com

#include<iostream>
using namespace  std;
class number
{
private:
int n;
public:
void getdata()
{
cout<<"Enter a no.";    //  << = insertion operator
cin>>n;    // >> = extraction operator
}
  int oddoreven()
  {
  if(n%2==0)
    return 0;
    else
    return 1;
  }
  void showresult()
  {
  int r;
  r= oddoreven();
    if(r==0)
 
        cout<<"even number";
        else
        cout<<"odd number";
  }

};
int main()
{
number N;
N.getdata();
    N.showresult();
 
    return 0;
}


OUTPUT:
Enter a no.4
even number

Translate

Popular Posts