Practical 11
#include<iostream>
#include<iomanip>
using namespace std;
class Number
{
int a,b;
int largest();
public:
void getdata();
void putdata();
};
void Nimber::getdata()
{
cout << "\t\tEnter number 1: ";
cin >> a;
cout << "\t\tEnter number 2: ";
cin >> b;
}
void Number::putdata()
{
cout << "\t\tNumbers are " << a << " and " << b << endl
<< "\t\tLargest of them is " << largest() << endl;
}
int Number::largest()
{
if(a>b)
return a;
else
return b;
}
int main()
{
Number a;
a.getdata();
a.putdata();
return 0;
}
output:
enter num1 : 4
enter num2 : 8
largest of them is 8
No comments:
Post a Comment