1. In the code editor, you are provided with a main() function that asks the user for 4 integer inputs and passes these to the getBest() function call. 2. Your task is to declare and define this getBest() function which has the following details: Return type - int Name - getBest Parameters - 4 integers Description - returns the highest integer passed DO NOT EDIT ANYTHING IN THE MAIN Input 1. First integer 2. Second integer 3. Third integer 4. Fourth integer This is the given code: #includeusing namespace std; int main(void) { int a, b, c, d; cout << "Enter a: "; cin >> a; cout << "Enter b: "; cin >> b; cout << "Enter c: "; cin >> c; cout << "Enter d: "; cin >> d; cout << "Highest integer = " << highest; return 0; }
The Answer to the Question
is below this banner.
Can't find a solution anywhere?
NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?
Get the Answers Now!You will get a detailed answer to your question or assignment in the shortest time possible.
Here's the Solution to this Question
#include <iostream>
#include <string>
using namespace std;
int getBest(int a, int b, int c, int d)
{
int best = a;
if (best < b)
best = b;
if (best < c)
best = c;
if (best < d)
best = d;
return best;
}
int main(void)
{
int a, b, c, d;
cout << "Enter a: ";
cin >> a;
cout << "Enter b: ";
cin >> b;
cout << "Enter c: ";
cin >> c;
cout << "Enter d: ";
cin >> d;
cout << "Highest integer = " << getBest(a,b,c,d);
return 0;
}