PROGRAM CONTROL STRUCTURES

Get Started. It's Free
or sign up with your email address
PROGRAM CONTROL STRUCTURES by Mind Map: PROGRAM CONTROL  STRUCTURES

1. 1. Selection Control Structures

1.1. Sequence/sequential

1.1.1. - program segment where statements are executed in sequence, one after the other

1.2. Selection

1.2.1. selection control structure allows one set of statements to be executed if a condition is true and another set of actions to be executed if a condition is false

1.3. Repeatition

1.3.1. Programmer specifies an action to be repeated while some condition remains true

2. 2. Types of Operators

2.1. operator = (one equal sign)

2.2. operator == (two equal signs)

2.3. Nested if

2.3.1. -nested if statements are used to choose between several alternatives

2.4. switch statement

2.4.1. -Useful when variable or expression is tested for multiple values • Consists of a series of case labels and an optional default case • break is (almost always) necessary

3. 3. Loops Control

3.1. for statement

3.1.1. initialization; condition; increment) statement

3.1.2. its main function is to repeat statement while condition remains true

3.2. While statement

3.2.1. its functionality is simply to repeat statement while the condition set in expression is true

3.3. do…while statement

3.3.1. Its functionality is exactly the same as the while loop, except that condition in the do-while loop is evaluated after the execution of statement inside the loop instead of before, granting at least one execution of statement inside the loop even if condition is never fulfilled.

4. 5. Control Transfer Statement

4.1. quitting the loops

4.1.1. break statement

4.2. continuing the loops

4.2.1. continue statement

4.3. Terminating the program using exit() function

5. 4. The Difference Between Different Types of Loops Structures

5.1. WHILE

5.1.1. The condition is evaluated first and if it is immediately false, statements inside the loop are never executed.

5.1.2. In the while statement, the conditional expression is evaluated before the statements inside the loop are being executed

5.2. DO-WHILE

5.2.1. Statements inside the loop are executed before the condition is tested and so, statements inside the loop are guaranteed to be executed at least once.

5.2.2. In the do-while statement, the conditional expression is evaluated after statements inside the loop are being executed