Q:

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

0

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

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Classes and Objects Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C++ Program to find Sum of odd numbers bet... >>
<< Write a C++ program to display Student details usi...