Answer to Question #211664 in C++ for Raju

Question #211664

write a program to find out big number from 2 value using class and object


1
Expert's answer
2021-06-29T00:12:57-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS