C++ Program : To find the given number is even or odd




#include<iostream.h>
#include<conio.h>
class number
{
   public:
   int no;
   int iseven()
   {
      if(no%2==0)
         return 1;
      else
         return 0;
   }
};

int main()
{
   clrscr();
   number x;
   cout<<"Enter the number :";
   cin>>x.no;
   if(x.iseven())
      cout<<"The number is even";
   else
      cout<<"The number is odd";
   getch();
   return 0;
}

Class diagram 

(click image to view large)

 

 



Related Posts:

0 comments:

Post a Comment