list the basic control structures used in most imperative la
list the basic control structures used in most imperative languages
Solution
Answer:
Computations in imperative-language programs evaluating expressions – reading variables, executing operations Assigning resulting values to variables Selecting among alternative control flow paths Causing repeated execution. A control structure is a control statement and the statements whose execution it controls. Most programming languages follow a single thread of control (or scheduling).
There are three basic types of control structures are sequential, selection and iteration in most imperative languages. They can be combined in any way to solve a specified problem.
Sequential Structure:
Sequential is the default control structure, statements are executed line by line in the order in which they appear. The selection structure is used to test a condition. A sequence of statements is executed depending on whether or not the condition it true or false. This means the program chooses between two or more alternative paths. Condition refers to any expression or value that returns a Boolean value, meaning true or false.
Selection Structure:
The three main types of selection statements are \"if,\" \"if/else\" and \"switch\" statements. The most basic and common is the \"if\" statement. The \"if\" and \"if/else\" statements can be nested. Switch statements are ideally used when there are multiple cases to choose from.
Iterative Structure:
The iteration or repetition structure repeatedly executes a series of statements as long as the condition is true. The condition may be predefined or open-ended. \"While,\" \"do/while\" and \"for\" loop are the three types of iteration statements. A loop can either be event controlled or counter controlled. An event-controlled loop executes a sequence of statements till and event occurs while a counter-controlled loop executes the statements a predetermined number of times.
