Answer to Question #324590 in C++ for Secret Agent

Question #324590

Preserving the Gene Pool


by CodeChum Admin



In order to make sure that the future generations will grow into great beings, we must make sure that the gene pool consists of the best genes. In order to do that, we must compare genes from each other and find out which one is the best!





Instructions:



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.


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



Output



Enter·a:·10


Enter·b:·3


Enter·c:·15


Enter·d:·14


Highest·integer·=·15


1
Expert's answer
2022-04-06T02:27:50-0400




#include<iostream>
#include <string>
using namespace std;


int  getBest(int a,int b,int c,int d){
	int highest=a;
	if(b>highest){
		highest=b;
	}
	if(c>highest){
		highest=c;
	}
	
	if(d>highest){
		highest=d;
	}
	
	return highest; 
}


int main()
{
	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)<<"\n\n";
	
	
	system("pause");
	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