Site pages
Current course
Participants
General
Topic 1
Topic 2
Topic 3
Topic 4
Topic 5
Topic 6
Topic 7
Topic 8
Topic 9
Topic 10
Topic 11
Topic 12
Topic 13
Topic 14
Topic 15
Topic 16
Topic 17
Topic 18
Topic 19
Topic 20
Topic 21
Topic 22
Topic 23
Topic 24
Topic 25
Topic 26
Topic 27
Selection Constructs
It is also known as conditional construct. It is used to indicate decision in a program. There are different kinds of selection constructs. They are
1. IF ....THEN CONSTRUCT : This structure is also called as the ‘one-way branch ‘ decision structure. IF test-condition then Statement 2 Endif In some situations, certain statements have to be executed only if a certain condition is met. In such cases, a test condition is specified. The test-condition is a Boolean expression which when tested results in TRUE or FALSE. When the condition is TRUE, statement enclosed between THEN and ENDIF are executed. If the condition is false, the statements are ignored and control is transferred to the statement following the if..then structure. Example : Draw a flowchart to print the absolute value of an integer
True False 2. If ..Then ….Else Construct This structure is also called as the ‘two-way branch” decision structure If test-condition then Statement 1 Else Statement 2 Endif If test-condition results in TRUE value, statement 1 is executed. If it is FALSE, statement 2 is executed. Statement 1 , Statement 2 can either be a single statement or a set of simple statements. Example :Draw a flowchart to find the largest of two numbers |