Powered by Blogger.

Sunday, February 3, 2013

Comparision

#include<iostream.h>
#include<conio.h>


class comparison
{
      int x,y,max;
      public:
             void getdata(int a,int b);
             void largest(void);
             void print(void);
             };
            
             void comparison::getdata(int a,int b)
             {
                  x=a;
                  y=b;
                  }
            void comparison::largest()
            {
                 if(x>y)
                 max=x;
                 else
                 max=y;
                 }
           
            void comparison::print()
            {
                 cout<<"\nThe Largest Number : "<<max<<endl;
                 }
                
            int main()
            {
                comparison com;
                int a,b;
               
                cout<<"Enter Two numbers : ";
                cin>>a>>b;;
               
               
                com.getdata(a,b);
                com.largest();
                com.print();
               
                getch();
                }

0 comments:

Post a Comment