Answer to Question #328092 in C for EmEm

Question #328092

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:

  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:
  3. Return type - int
  4. Name - getBest
  5. Parameters - 4 integers
  6. Description - returns the highest integer passed
  7. DO NOT EDIT ANYTHING IN THE MAIN

Input


1. First integer

2. Second integer

3. Third integer

4. Fourth integer


1
Expert's answer
2022-04-13T07:33:12-0400




#include <stdio.h>


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 number1,number2,number3,number4;




	printf("Enter the first number: ");
	scanf("%d",&number1);
	printf("Enter the second number: ");
	scanf("%d",&number2);
	printf("Enter the third number: ");
	scanf("%d",&number3);
	printf("Enter the fourth number: ");
	scanf("%d",&number4);


	
	printf("Highest integer = %d\n\n",getBest(number1,number2,number3,number4));




	getchar();
	getchar();
	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