Source code
#include <iostream>
using namespace std;
class subtraction{
private:
int x;
int y;
public:
void getData(){
cout<<"\nEnter first number: ";
cin>>x;
cout<<"\nEnter second number: ";
cin>>y;
}
void subtract(){
int sub=x-y;
cout<<"\n"<<x<<" - "<<y<<" = "<<sub;
}
};
int main()
{
subtraction s1;
s1.getData();
s1.subtract();
return 0;
}
Output
Comments
Leave a comment