Write a C++ Program to find Largest among 3 numbers using classes

By | 28.12.2016

Write a C++ Program to find Largest among 3 numbers using classes

#include<iostream>
using namespace std;
class greatest
{
        private:
                int x,y,z;
    public:
        void input()
        {
                cout<<"Enter 3 nos.";
                cin>>x>>y>>z;
        }
        void calc()
        {
                int r;
                r=((x>y)&&(x>z)?x:(y>x)&&(y>z)?y:z);
                cout<<"Greatest no:"<<r;
        }
};
int main()
{
        greatest g;
        g.input();
        g.calc();
        
}

 

OUTPUT ::

 

Enter 3 nos.5 9 2 

Greatest no: 9

 

 

4.3 7 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments