Answer to Question #340167 in C++ for Chubby

Question #340167

Make a c++ program that will print the highest number of the three input number using a function.


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


float large(float n1, float n2, float n3){
	if(n1 >= n2 && n1 >= n3)
        return n1;


    if(n2 >= n1 && n2 >= n3)
        return n2;
    
    if(n3 >= n1 && n3 >= n2)
        return n3;
}
int main() {    
    float n1, n2, n3;


    cout << "Enter three numbers:\n";
    cin >> n1 >> n2 >> n3;


    cout << "Largest number: " << large(n1, n2, n3);
  
    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