Answer to Question #340321 in C++ for duh

Question #340321

define a function that ask a user to enter three numbers and program display the largest using function with return value and argument




1
Expert's answer
2022-05-12T08:21:17-0400
#include <iostream>
using namespace std;

double Largest();

int main() {
 
 cout<<"Largest: "<< Largest();
    cout<<endl;
    
return 0;
}
double Largest(){
    
    double n1,n2,n3;
    
    cout << "Enter three numbers: ";
    cin >> n1 >> n2 >> n3;

    if(n1 >= n2 && n1 >= n3)
        return n1;

    if(n2 >= n1 && n2 >= n3)
        return n2;
    
    if(n3 >= n1 && n3 >= n2)
        return n3;
}

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