Selection Statements Flashcards
Algorithm is a procedure for solving a problem in terms of:
- the actions to be executed
- the order in which these actions are to be executed
It is specifying the order in which statements are to be executed in a computer program
Program Control
It is an artificial and informal language that helps you develop
algorithms
Pseudocode
Not executed on computers – rather, helps us “think out” a program before starting to write the code in a programming language like C
Pseudocode
It is a graphical representation of an algorithm or of a portion of an algorithm
Flowcharts
Types of Control Structures
- Sequence
- Selection
- Iteration
- Function Call
Statements are executed in a specified order
Sequence
No statement is skipped and no statement is executed more than once.
Sequence
It selects a statement to execute on the basis
of condition
Selection
Examples of Selection
- if statement
- switch statement
- conditional operator
When statements are executed more than one time
Looping/Iteration
Examples of Looping/Iteration
- while loop
- for loop
- do-while loop
Allows a program to choose
between two alternatives by
testing the value of an expression
If Statement
Consists of a test expression
followed by one or more
statements
If Statement