Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Computer

Science O.L.
(New Syllabus)

“Everybody should learn to program a computer,


because it teaches you how to think.”
- Steve Jobs
Practical

01
Programming pt.5
(Conditional)
Programming pt.5
● Nested IFs

● Possibilities

● CASE..DO..OTHERWISE..ENDCASE
Quick question
Write a pseudocode, which takes the students mark and exam full mark as input and output
their performance according to the following table.
-Validate any entry from the user
Hint: calculate the percentage
Quick question
Write a program which accepts three real numbers, if the first number is bigger than the second number and the third
number print "The first is biggest" otherwise is the "The smallest".

Code:
Quick question
Design a program that takes from the user three numbers and show to the user the biggest number

Code:
Bonus Question +5
Design a program that takes from the user three numbers and show to the user in descending order.
Example:
- 1 , 67 ,5  67 , 5 , 1
-3,3,33 , 3, 3
Code:
CASE conditional
New conditional tool.
Used only under two constraints.
Condition asks only using = sign (no ranges) and condition contains only one variable.

CASE [ VARIABLE ] OF

[ Case 1 ] : [ Code ]
[ Case 2 ] : [ Code ]
[ Case 3 ] : [ Code ]
[ Case 4 ] : [ Code ]

Otherwise
[ Final Case ]

ENDCASE
Quick question Design a program that reads from the user the class year and outputs the class name according to the following :
Class Year Class Name
9 Pre-IG
10 Freshman
11 Junior
12 Senior

Code: Display Invalid class year if the class year does not exist in the table
Quick question
Write a pseudocode, which takes the a device number as input and output their device name and its price according
to the following table

IF the device number is not valid, an error


message should be displayed!
Code:

You might also like