Answer to Question #263855 in C++ for Aashi

Question #263855

WAP to find Largest among 3 numbers using class (Display all the three numbers along with largest value)

1
Expert's answer
2021-11-10T09:36:37-0500
#include <iostream>
#include <iomanip>
using namespace std;
class Display{
    public:
    int n1;
    int n2;
    int n3;
void display()
   {
    cout<<"Enter first number: ";
    cin>>n1;
    cout<<"Enter second number: ";
    cin>>n2;
    cout<<"Enter third number: ";
    cin>>n3;
    cout<<"display all numbers\n"<<n1<<setw(20)<<n2<<setw(20)<<n3<<endl;
    if ((n1>=n2) && (n1>=n3))
        cout<<"Largest value: "<<n1;
   else if ((n2>=n1) &&(n2>=n3))
        cout<<"Largest value: "<<n2;
    else if ((n3>=n1) && (n3>=n2))
        cout<<"Largest value: "<<n3;
    }
};


int main()
{
Display s;
s.display();
    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