Basic Control Flow

A computer program is a sequence of instructions that a computer follows to solve a problem. However, the order in which instructions are written and the order in which they are executed may differ. If every program executed instructions strictly in sequence, it would always run the same way. To create more complex programs that can make decisions based on user input or variable values, we need mechanisms to alter the flow of execution. This is known as control flow.

For example, consider a real-life scenario: "If the traffic light is green, keep moving; if yellow, then wait; if red, then stop." In programming, decision-making means choosing which statement to execute next based on the value of a variable or an expression. Constructs like 'if' and 'switch' allow programs to make decisions and change the flow of execution. These are called conditional statements, and they can be nested to create more complex control flows.

In this experiment, we focus on basic control flow mechanisms in programming, especially conditional constructs such as if, if-else, and switch-case. The aim is to understand how these constructs enable decision-making in programs and how they can be used to control the order of execution of statements.