38.3k views
4 votes
max is a function that accepts two int parameters and returns the value of the larger one. Two int variables, population1 and population2, have already been declared and initialized. Write an expression (not a statement!) whose value is the larger of population1 and population2 by calling max.

1 Answer

5 votes

Answer:

Value=max(populatio1,population2)

Explanation:

Assuming that two int variables, population1 and population2, have already been declared and initialized, we car write the next function:

max(population1,population2)

if population1 => population2

then var=population1

else var=population2

endif

return var

This function decides between two values population1 and population 2 and return the value of the larger one.

Note that we can have the option where population1 and population 2 are equal and doesn´t matter if we choose population1 or population2

User Erogol
by
8.8k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories