Chap 03 - Algorithm Design For Sequence Control Structure
Chap 03 - Algorithm Design For Sequence Control Structure
Chap 03 - Algorithm Design For Sequence Control Structure
03 Assignment Statements
01
Understanding about Data Type,
Data & Information
1.0 Understanding about Data Type, Data & Information
• Data that has a single value and • Can be broken down further to a
cannot be further broken into few primitive data. It means that a
small values. complex or composite data are
actually a collection of primitive
data.
1.2 Standard Data Type
Standard
Data Types
Boolean ▪ Logical or Boolean data consists of only two values: true and false.
(bool) ▪ True (1) and false (0).
02
Operators, Identifiers
(Variables and Constants)
2.1 Identifier
● One feature present in all computer languages is the identifier – allow us to
name data and other objects in the program.
● Identifier is used to define names to represent variables, constant and
name of function.
● Each piece of data in the computer is stored at a unique address.
● Different programming language use different rules to form identifier.
● In C++ :
○ consists of letters (capital letter A through Z, the lowercase letter a to z), digits
(0 through 9), and the underscore (no other symbols are permitted to form a
identifier.
○ the 1st character cannot be a digit - must be begin with a letter or underscore.
● Good identifier names are descriptive (by combining two or more words)
but short.
2.2 Variables
Operators
Operator Operation
● One of the most
important uses of a + Addition
computer is its ability to - Subtraction
Integral data type
calculate. * Multiplication
● To perform arithmetic
/ Division
operations (manipulate Floating-point
integral and floating-point % Modulus (Remainder) data type
data types). -- Decrement by 1
● The arithmetic operators: Integral data type
++ Increment by 1
2.5.2 Relational Operator
Operator Operation
● To compare the values
< Less than
of two operands.
<= Less than or equal to
● The evaluation result is
either TRUE (1) or > Greater than
FALSE (0). >= Greater than or equal to
● The relational
== Equal to
operators:
!= Not equal to
2.5.3 Logical Operator
Example (Pseudocode):
● This is basically where a program will
repeat a set of instructions until it Start
reaches a certain point where an event WHILE condition is true
has occurred (the condition is met) StatementA
ENDWHILE
● In a loop, you ask a question; if the End
answer requires an action, you perform
the action and ask the original question
again. If the question’s answer requires
that the action be taken again, you take
the action and then ask the original
question again.
5.5 Combination of Three Structure
repetition). do step A
do step B
● The three structures, can
if condition C is true then
be combined in an infinite do step D Selection
number of ways. For else
do step E
example: there can be a
endif
sequence of steps while condition F is true then Repetition
followed by a selection or do step G
repetition followed by
sequence.
5.6 How to Write a Detailed Algorithm Using Pseudocode?
Example: Start
● Basic pseudocode: Read length, width
Calculate area of a rectangle
Display area of a rectangle
End
● Expected screen:
5.6 How to Write a Detailed Algorithm Using Pseudocode?
Example: Example:
● Detailed pseudocode: ● Flowchart:
Start
Input:
Display “Enter length: ”
Read length
Display “Enter width: ”
Read width
Process:
area = length x width
Output:
Display “The area of a rectangle: ”, area
End
Thanks!
Do you have any
questions?