Write a C++ program to find Largest among 2 numbers using class
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 27 28 29 30 31 |
#include<iostream> using namespace std; class biggest { private: int a,b; public: void input(); void display(); }; void biggest::input() { cout<<"Enter 2 nos.:"; cin>>a>>b; } void biggest::display() { if(a>b) cout<<"Biggest no.:"<<a; else cout<<"Biggest no.:"<<b; } int main() { biggest b; b.input(); b.display(); } |
OUTPUT ::
1 2 3 |
Enter 2 nos.:33 44 Biggest no.:44 |