FIND THE LARGEST NUMBER USING CLASS IN CPP

 #include<iostream>

 using namespace std;
      class set{
      int m,n;
      public:
      void inputdata();
       
      void largest();

      };
      void set::inputdata(){
      cout<<"enter the value of m and n:"<<endl;
      cin>>m;
      cin>>n;
      };
      void set::largest(){
      if(m>=n){
          cout<<"largest="<<m<<endl;
      }
      else{
          cout<<"largest="<<n<<endl;
      }
  } 
       int main(){
       set x;
       x.inputdata();
       x.largest();
  
 return 0;
 }

Comments

Popular posts from this blog

250+ C Programs for Practice

FUNCTION OVERRIDING IN CPP