0% found this document useful (0 votes)
53 views10 pages

O-Level-Cs - Pseudocode - Iteration - Loop Structures

O Level/ IGCSE Computer Science - 2210 - Iteration and Loop Structures FOR TO NEXT while do endwhile return until

Uploaded by

shahanazais9681
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
0% found this document useful (0 votes)
53 views10 pages

O-Level-Cs - Pseudocode - Iteration - Loop Structures

O Level/ IGCSE Computer Science - 2210 - Iteration and Loop Structures FOR TO NEXT while do endwhile return until

Uploaded by

shahanazais9681
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 10

What is Pseudocode ?

Why is it important
O LEVEL IGCSE COMPUTER SCIENCE
SUBJECT CODE: 2210
ALGORITHM DESIGN AND PROBLEM SOLVING
What is Pseudocode? Why is it important?
• Pseudocode is a simple method of showing an algorithm. It describes what the
algorithm does by using English key words that are very similar to those used in
a high-level programming language.
• However, pseudocode is not bound by the strict syntax rules of a programming
language.
• But we use keywords and variables by giving meaningful names to it in the
same way we use in high level programming languages

High level
Problem Algorithm Pseudocode programming
Problem Algorithm Pseudocode

1)Get a number Number <- 0


Write a INPUT Number
2) Divide by 2
programme to Remainder <- Number % 2
3) If the reminder IF Remainder = 0
find if a given
is 0 show the is THEN OUTPUT Number ,“is an even
number is odd or
even otherwise ELSE OUTPUT Number, “is an odd
even
odd ENDIF
How to write a Pseudocode?
Variables and Assignment
• A value is assigned to an item/variable using the <- operator.

• The variable on the left of the ¨ is assigned the value of the expression on
the right. The expression on the right can be a single value or several values
combined with any of the following mathematical operators.
INPUT and OUTPUT Statement
• INPUT and OUTPUT are used for the entry of data and
display of information.
• INPUT Number
• INPUT StudentName
• INPUT Mark
• OUTPUT “Enter the name of the Student”
• OUTPUT “You are Pass”
• OUTPUT “You scored”, Mark
Problem Algorithm Pseudocode
1)Get the amount INPUT Amount
Write a
2) Find the discount Discount <- 0.2
programme to
amount DiscountPrice <- Amount *
find discounted Discount
3) Subtract the
price for a given FinalPrice<- Amount –
discount amount from
amount, DiscountPrice
the actual amount OUTPUT FinalPrice
discount is 20%
4) Output the answer
Iteration / Loop Structures
• Pseudocode includes these three different types of loop
structures

REPEAT … UNTIL WHILE … DO …


FOR … TO … A repetition, where the ENDWHILE
NEXT number of repeats is A repetition, where the
A set number of not known, that is number of repeats is
repetitions completed at least not known, that may
once never be completed
All types of loops can all perform the same task, for
example displaying ten stars
WHILE… DO…
FOR … TO … NEXT REPEAT … UNTIL
Counter ← 0
ENDWHILE
Counter ← 0
REPEAT
FOR Counter ← 1 TO 10 OUTPUT "*"
WHILE Counter < 10 DO
OUTPUT "*" OUTPUT "*"
Counter ← Counter + 1 Counter ← Counter + 1
NEXT UNTIL Counter > 9 ENDWHILE
A variable is set up, with a start value This loop structure is used when the This loop structure is used when the
and an end value, this variable is number of repetitions is not known number of repetitions is not known
incremented in steps of one until the and the actions are repeated UNTIL and the actions are repeated UNTIL
end value is reached and the iteration a given condition becomes true. The a given condition becomes true. The
finishes. The variable can be used actions in this loop are always actions in this loop are always
within the loop so long as its value is completed at least once. This is a completed at least once. This is a
not post-condition post-condition
changed. This type of loop is very loop as the test for exiting the loop loop as the test for exiting the loop
useful for reading values into lists with is at the end of the loop. is at the end of the loop.
a known length.
Write pseudocode to print numbers from 1 to 110
using all three types of loops

WHILE… DO…
FOR … TO … NEXT REPEAT … UNTIL ENDWHILE

You might also like