Make a c++ program that will print the highest number of the three input number using a function.
#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;
}
Comments
Leave a comment