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

PSEUDOCODE

Pseudocode is a simple way to show algorithms using English-like syntax. It describes what an algorithm does using terms similar to programming languages. The pseudocode document defines common programming concepts like variables, data types, input/output, arrays, and conditional statements. It provides examples of how to declare variables, assign values, and write conditional logic using pseudocode notation.

Uploaded by

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

PSEUDOCODE

Pseudocode is a simple way to show algorithms using English-like syntax. It describes what an algorithm does using terms similar to programming languages. The pseudocode document defines common programming concepts like variables, data types, input/output, arrays, and conditional statements. It provides examples of how to declare variables, assign values, and write conditional logic using pseudocode notation.

Uploaded by

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

PSEUDOCODE

Wednesday, 28 February 2024 13:52

PSEUDOCODE - A simple way of showing an algorithm.


It describes what an algorithm does by using English words that are very similar to those used in a high

Pseudocode
• Declaration & Usage of Variables & Constants

• Variable – Store of data which changes during execution of the program (due to user input)

• Constant – Store of data that remains the same during the execution of the program

• Basic Data Type



Integer –whole Number e.g. 2; 8; 100

• Real – Decimal Number e.g. 7.00; 5.64

• Char – Single Character e.g. a; Y

• String – Multiple Characters (Text) e.g. ZNotes; COOL

• Boolean – Only 2 Values e.g. True/False; Yes/No; 0/1

• Input & Output (READ & PRINT)


• – Used to receive and display data to the user respectively. (It is recommended to use input and

EXAMPLE :

INPUT Name
OUTPUT "Hello Mr." , Name
// Alternatively //
READ Name
PRINT "Hello Mr," , Name
• Declaration of variable
- A variable/constant can be declared by the following manner
h level programming language.

d output commands)
// Alternatively //
READ Name
PRINT "Hello Mr," , Name
• Declaration of variable
- A variable/constant can be declared by the following manner

TO BETTER UNDERSTAND WHAT IS BEING SAID :

Declaring a variable means introducing it to your program and specifying its name and type.
It's like giving a name to something (the variable) and saying what kind of thing it is (the type

Imagine you have a box (the variable) and you want to label it with a name (the variable nam
and specify what can go inside it (the type).
For example, you might have a box called "age" where you'll put numbers representing som
So, when you declare a variable in your program, you're essentially creating that labeled bo

SOMEONE'S AGE

DECLARE [Variable Name] : [DATATYPE OF VARIABLE]

This keyword is used to indicate that you're declaring something

LITTLE QUIZ :

VARIABLE NAME________________________

• DATATYPE OF A VARIABLE :_____________________

• Array:
e).

me)

meone's age.
ox and saying what kind of information it will hold
• DATATYPE OF A VARIABLE :_____________________

• Array:
• Array is similar to variable but it can store multiple values of same datatype under single nam

DECLARE [ARRAYNAME] : ARRAY [Lower Limit : Upper Limit ] OF [DATATYPE]

• EXAMPLE:

DECLARE numbers : ARRAY [1:5] OF INTEGER specifies the range or size of the a
The "Lower Limit" and "Upper Lim
represent the boundaries of the a

ARRAY NAME
This is where you specify INDICATES WHAT FOLLOWS AN ARRAY
the name of the array
you're declaring.

• Assignment - Each variable is assigned using a left arrow.

[VARIABLE NAME] <---- [Value to be assigned]


Example :

ARRAYNAME[IndexValue] <---- [Value to be assigned]


Example :

For instance, if you have an array of numbers like [10, 20, 30, 40, 50], LETS SAY THESE
the index values and corresponding elements would be:

• Index 0: Element 10
• Index 1: Element 20
• Index 2: Element 30
• Index 3: Element 40
• Index 4: Element 50

THINGS TO CONSIDER:
• All keywords are written in capital letters
me

array.
mit"
array indices.

E ARE TEMPERATURES
• Index 3: Element 40
• Index 4: Element 50

THINGS TO CONSIDER:
• All keywords are written in capital letters
• Whenever conditional and loop statements are used , repeated or selected statements a

PSEUDOCODES FOR CONDITIONAL STATEMENTS

- THERE ARE CONDITIONS INVOLVED


- THEY ARE TWO TYPES OF CONDITIONAL STATEMENTS

1. IF… THEN.. ELSE


( used if a condition is true or false )

- IF…THEN…ELSE…ENDIF CONDITION =

CONSEQUENCE=

THE ENDING OF
STATEMENT
IF THEN ELSE
END : ENDIF

Tip to identi
A CONSEQU

QUESTIONS :
A) WRITE A PROGRAM THAT ONLY ACCEPTS CHILDREN ABOVE 18 TO RIDE AND DECLIN
BELOW 18

BEFORE ATTEMPTING THE QUESTION :


- LOOK FOR THE CONDITION AND THE CONSEQUENCE

CONDITION :
CONSEQUENCE :
METHOD:
are indented by two spaces

ASSOCIATION: OUTPUT
-------> DISPLAYS

F ANY CONDITIONAL

ify : CONDISTION AND


UENCE

NES CHILDREN THAT ARE


- LOOK FOR THE CONDITION AND THE CONSEQUENCE

CONDITION :
CONSEQUENCE :
METHOD:

IF AGE>18 THEN
OUTPUT " CAN RIDE"
ELSE
OUTPUT" CANNOT RIDE"
ENDIF

2.) CASE…OF…OTHERWISE…ENDCASE – Multiple conditions and corre

TIP TO IDENTIFY :MU


OPTIONS AND CONS
esponding consequences

ULTIPLE CONDITIONS
SEQUENCES

You might also like