Computer Science, asked by TbiaSamishta, 1 year ago

In the process of grouping the people into child, young and old categories, depending on the age group, which control statement would you like to choose any why?

Answers

Answered by Secondman
3

"In the process of grouping, the people into child, young, and old categories, depending on the age group, the control statement that I would like to choose is if else-if statements.

The reason behind that is that while checking for age group categories, I will have to compare the variable containing the age of the user with the values setting the boundaries of different age groups.

The statements like if and else-if provides a feasible way to do this, whereas switch clause can only check for equality and hence cannot do other comparisons. Because of this, it would take a lot of case statements to solve the same problem using switch clause."

Similar questions