even or odd number c++ || class program - InTerestinG321

even or odd number c++ || class program

even or odd number class program:

In this program find the entered number is Even number or Odd number. Which number is divisible by 2 is known as an even number, and which number is not divisible by 2 is known as an odd number.




Program:

#include<iostream> using namespace std; class even { int n,i; public: void read(); void print(); }; void even::read() { cout<<"enter the number\n"; cin>>n; } void even::print() { if(n%2==0) { cout<<"even number\n"; } else { cout<<"odd number\n"; } } int main() { even ob1; ob1.read(); ob1.print(); }

Output:

Click Here for Executable CPP file:









3 comments: