0% found this document useful (0 votes)
4 views

Problem Solving Structures

Uploaded by

jhpdcb42cp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Problem Solving Structures

Uploaded by

jhpdcb42cp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PROBLEM SOLVING

STRUCTURES

The three control structures used in


creating algorithms are:-
1. Sequence
2. Selection/conditional
3. Iteration/Repetition/Loops
SEQUENCE

Instructions are carried out one after the


other without any decisions to be made.

EXAMPLE
START
DISPLAY ‘Please enter 2 numbers’
READ NUM1, NUM2
SUM = NUM1 + NUM2
PRINT ‘The sum is’, SUM
END
CONDITIONAL STATEMENTS

Conditional statements allow decisions


to be made in a program. This
includes deciding which statements
are to be executed if true. For
example you might want a set of
statements to execute only if certain
conditions are met; otherwise, the
statements would not be executed.
Examples of conditional
statements
◼ IF-THEN ◼ IF-THEN-ELSE
The general form The general form
of an IF-THEN of an IF-THEN-
statement ELSE statement
IF (condition) THEN IF (condition) THEN
(statement if (statement if True)
true) ELSE
ENDIF (statement if False)
ENDIF
IF-THEN Statement

Write an algorithm to show if someone is a child


once the age is under 13 years old and print
‘CHILD’.

Answer
START
Display ‘Please enter your age’
Read age
IF age < 13 THEN
Print ‘CHILD’
Endif
END
IF-THEN-ELSE Statement
Write a pseudocode algorithm to show if Kay is a child
once she is under 13 years old, or if she is not a child it
would print a statement.

Answer
START
Display ‘Please enter the age of Kay’
Read age
IF age < 13 THEN
Print ”Kay is a child”
Else
Print ”Kay is not a child”
Endif
END

You might also like