0% found this document useful (0 votes)
37 views3 pages

RevisionIOA Statements Nov 2, 2020

This document discusses input, assignment, and output statements in pseudocode algorithms. It explains that input statements are used to get data from outside the computer into a variable, assignment statements assign values to variables, and output statements display information to the user. Examples are given of reading input into variables, performing calculations by assigning the result to a variable, and printing output. Common operators used in pseudocode like addition, comparison, and assignment are also listed.

Uploaded by

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

RevisionIOA Statements Nov 2, 2020

This document discusses input, assignment, and output statements in pseudocode algorithms. It explains that input statements are used to get data from outside the computer into a variable, assignment statements assign values to variables, and output statements display information to the user. Examples are given of reading input into variables, performing calculations by assigning the result to a variable, and printing output. Common operators used in pseudocode like addition, comparison, and assignment are also listed.

Uploaded by

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

LESSON 4

TOPIC: WRITING PSEUDOCODE ALGORITHMS–INPUT,


ASSIGNMENT AND OUTPUT STATEMENTS
Line 2 - This instruction allows auser toenter
INPUT STATEMENT
a value that will be stored ina variablecalled
The input statement is used to get data from B.
outside the computer via some input device
into a variable.
ASSIGNMENTSTATEMENT
Variable Assignment statements are usedtogiveinitialvalue to
variables and to change thevalue
This is a storage location for storing data that
assigned to a variable.
may change during the processing of the
computer program.
Layout
Lvalue = Rvalue
Variable Name Checklist
Read Num1 (Line 1)
 The name must not be too long.
Read Num2 (Line 2)
Lvalue refers to the variable as thestorage
 The name must be descriptive of the data
being stored. location. Rvalue can be a value, theresult ofan
expression or the contents of another
 There should be no space between variable
variable.
names consisting of two words. For
example a variable name to store a unit
Example
cost can be written as UnitCost or
Rvalue as a value
Unit_Cost. A space between the two
Num1 = 6
words is a syntax error.
 The variable name must not begin with
Lvalue
numbers or special characters e.g. *, , .
Rvalue as the result of anexpression
 Variable names should be consistent
Sum = Num1 + Num2
throughout the pseudocode algorithm.
That is a variable name chosen at the start
Lvalue
of a pseudocode algorithm should remain
the same from start to finish.
Rvalue as the contents of anothervariable
Num1 = Num2
Layout Lvalue
Read Variable Name
or Practice Question
Input Variable Name
Write a pseudocode algorithmtoreadtwo
numbers and find their sum.
Practice Question
Write a pseudocode algorithm to read two
Solution
numbers into variable A and B.

Solution Sum = Num1 +Num2 (Line 3)


Read A (Line 1)
Read B (Line 2)
Explanation
Line 3 – This instruction will addthevalue
Explanation
stored in the variable Num1 tothevaluestored
Line 1 - This instruction allows a user to enter
in the variable Num2. The result of the
a value that will be stored in a variable called
addition will be stored in a variablecalled
A. Sum.

18 FPowell [email protected]
Operator Explanation
+ Addition
- Subtraction
Read Num1 (Line 1)
Read Num2 (Line 2)
* Multiplication
Print Sum (Line 4)
= Equal to
<> Not equal to
OUTPUT STATEMENT
The output statement is used to get information
> Greater than
to the programmer or computer user.
Explanation
Line 4 – This instruction will displaythe
Layout1 thecontents
> Less thanmessage “The sumis” as well as

Read Num1 (Line 1)


Print Variable Name
stored in the variable Sum.
>= Greater thanor equal to
Read Num2 (Line 2)
or
Sum = Num1 + Num2 (Line 3)
<= Less thanor equal to
Write Variable Name

Layout2 OPERATORS
USEDINPSEUDOCODEALGORITHMS
Print “Message”, Variable Name
or The following operators are usedwhendeveloping
pseudocode algorithms that require
Write “Message”, Variable Name
calculations and comparisons.

Practice Question
Write a pseudocode algorithm to read two numbers and find their sum. Print the
results.

Solution1

Sum = Num1 + Num2 (Line 3)

Explanation
Line 4 – This instruction will display the
contents stored in the variable Sum.

Solution2

Print “The sum is”, Sum (Line 4)

19 FPowell [email protected]

You might also like