WAP in C++ to find the biggest of three numbers using friend function.
#include<iostream>
using namespace std;
class Largest {
private:
int M, N, P;
public:
void enter() {
cout << "Enter the three intergers:"<<endl;
cin >> M >> N>>P;
}
friend void get(Largest y);
};
void get(Largest y) {
if (y.M > y.N && y.M > y.P) {
cout << "The biggest number is:" << y.M;
} else if (y.N > y.P) {
cout << "The biggest number is:" << y.N;
} else {
cout << "The biggest number is:" << y.P;
}
}
int main() {
Largest y;
y.enter();
get(y);
return 0;
}
Comments
Leave a comment