MOBILE APPLICATION DEVELOPMENT - Program Structures + Classes and Objects
MOBILE APPLICATION DEVELOPMENT - Program Structures + Classes and Objects
PROGRAMMING STRUCTURES
Well structured Programs may be written using 3 structures namely:
SEQUENCE – One instruction at a time from top to bottom.
SELECTION – Used when the computer needs to make decision as
to which path to follow. The normal flow/sequence of execution of
instructions is altered Conditionally or Unconditionally.
ITERATION/LOOP – Simply means repetition of one or more
instructions a given number of times (Counter controlled) or until a
condition no longer exists (Sentinel controlled).
1
3/12/2024
PROGRAMMING STRUCTURES
SEQUENCE STRUCTURE – One instruction at a time from top
to bottom.
PROGRAMMING STRUCTURES
SELECTION STRUCTURE – Conditional: A criteria is evaluated
to know what path (instructions to execute) is desired. This
involves writing Boolean expressions:
2
3/12/2024
PROGRAMMING STRUCTURES
SELECTION STRUCTURE – Unconditional: No criteria is evaluated
before normal flow of program execution is altered. E.g. Function
call, use of the return, break, continue statements etc.
PROGRAMMING STRUCTURES
ITERATION/LOOP STRUCTURE – Counter Controlled:
Repetitions can be counted (determined) before the loop is
executed. Involves the use of a counter variable.
3
3/12/2024
PROGRAMMING STRUCTURES
ITERATION/LOOP STRUCTURE – Sentinel Controlled: Exact
number of repetitions cannot be determined before the loop is executed.
Iteration continues until a condition is no longer satisfied. E.g. Input of data
from the user and validation of same.
PROGRAMMING STRUCTURES
The break & continue Statements– break is basically used to
unconditionally terminate a loop or a switch statement while
continue is used to unconditionally skip to the next iteration.
4
3/12/2024
5
3/12/2024
Second Compartment
Third Compartment
6
3/12/2024
7
3/12/2024
8
3/12/2024
9
3/12/2024
10