Answer to Question #238486 in C++ for Avi

Question #238486

WAP in C++ to find the biggest of three numbers using friend function.


1
Expert's answer
2021-09-17T11:32:03-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS