EVEN OR ODD
#include "iostream.h"
#include "conio.h"
class eo
{
private:
int n;
public:
void accept ()
{
cout << "Enter a number: ";
cin >> n;
}
void cal ();
};
void eo :: cal ()
{
switch (n)
{
case 0:
cout << "Number is zero";
break;
default:
switch (n%2)
{
case 0:
cout << "It is an Even number";
break;
default:
cout << "It is an Odd number";
}
}
}
void main ()
{
clrscr ();
eo E;
E.accept ();
E.cal ();
getch ();
}
Get the executable ( .exe ) file for this program..
Download
No comments:
Post a Comment