Q:

What are the three types of control structures?

A:

Quick Answer

The three basic types of control structures are sequential, selection and iteration. They can be combined in any way to solve a specified problem.

Continue Reading

Full Answer

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.

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.

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.

Learn more about Computer Programming
Sources:

Related Questions

Explore