write a program to find out big number from 2 value using class and object
#include <iostream>
using namespace std;
class BigNumber{
private:
int x;
int y;
public:
void setX(int a){
x=a;
}
int getX(){
return x;
}
void setY(int b){
y=b;
}
int getY(){
return y;
}
int getBig(){
if (x>y)
return x;
else
return y;
}
};
int main()
{
int n1,n2;
cout<<"\nEnter first number: ";
cin>>n1;
cout<<"\nEnter second number: ";
cin>>n2;
BigNumber bn;
bn.setX(n1);
bn.setY(n2);
cout<<"\nThe bigger number between "<<bn.getX()<<" and "<<bn.getY()<<" is: "<<bn.getBig();
return 0;
}
Comments
Leave a comment