Write a C++ Program to find Largest among 3 numbers using classes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#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 ::
1 2 3 |
Enter 3 nos.5 9 2 Greatest no: 9 |