prac_010.cpp (533B)
1 /* check odd or even */ 2 3 #include <iostream> 4 using namespace std; 5 6 class ooe { 7 int n; 8 9 public: 10 void input(); 11 void calcdisp(); 12 }; 13 14 void ooe::input() { 15 cout << "Enter the number : "; 16 cin >> n; 17 } 18 19 void ooe::calcdisp() { 20 if (n == 0) { 21 cout << "0 is neither an odd nor an even number."; 22 } 23 else if (n % 2 == 0) { 24 cout << n << " is a even number."; 25 } 26 else { 27 cout << n << " is a odd number."; 28 } 29 } 30 31 int main() { 32 ooe a; 33 a.input(); 34 a.calcdisp(); 35 return 0; 36 }