Give a real-world example of a selection control structure.
1 answer
A real-world example of a selection control structure is a traffic light. A traffic light contains multiple lights, such as red, yellow, and green, and it switches between them based on certain conditions or criteria. The selection control structure determines which light should be turned on at a particular time, considering factors such as the presence of vehicles or pedestrians, traffic flow, and signal timing. For instance, when there is heavy traffic on one side of the intersection, the control structure selects the appropriate light to give that lane more time, allowing vehicles to pass through efficiently.