Data Type Purpose / Description Example Values
INTEGER Whole numbers (positive or -10, 0, 35
negative)
REAL Numbers with decimal points 3.14, -0.75, 100.0
BOOLEAN Stores logical values TRUE, FALSE
CHAR A single character 'A', '3', '$'
STRING A sequence of characters "Hello", "123abc"
Pseudocode Declarations-
DECLARE variable : datatype
Assignment-
VARIABLE← 𝑣𝑎𝑙𝑢𝑒/𝑒𝑥𝑝𝑟𝑒𝑠𝑠𝑖𝑜𝑛/𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
Practice Fill-in-the-Blanks
1. DECLARE score : ______ → To store marks like 88
2. DECLARE temperature : ______ → To store 37.5
3. DECLARE pass : ______ → TRUE or FALSE
4. DECLARE message : ______ → To store "Good luck!"
5. SET message as “All the best”- ______________________________
6. SET pass to TRUE if score is greater than or equal to 60-
_________________________________
Operators-
Arithmetic_Operator Meaning Example Result
+ Addition 5+2 7
- Subtraction 9-4 5
* Multiplication 6*3 18
/ Division 10 / 2 5
MOD Modulus (Remainder) 7 MOD 3 1
DIV Integer Division 7 DIV 3 2
^ Exponentiation 2^3 8
Relational_Operator Meaning Example Result
= Equal to 5=5 TRUE
<> Not equal to 6 <> 4 TRUE
> Greater than 10 > 5 TRUE
< Less than 3<1 FALSE
>= Greater than or equal to 5 >= 5 TRUE
<= Less than or equal to 4 <= 3 FALSE
Logical_Operator Meaning Example Result
AND Both conditions must be TRUE (age > 10 AND age < 20) TRUE if age is 15
OR At least one must be TRUE (x = 5 OR x = 10) TRUE if x is 5 or 10
NOT Reverses the condition NOT (x = 5) TRUE if x <> 5
Note: Arithmetic, Logical and relational operators are used in conditions.(because they always evaluate
to True/False)
Quick Fill-in-the-Blank Practice
1. 7 MOD 4 = ___
2. 10 DIV 3 = ___
3. NOT (5 = 5) returns → ______
4. (6 > 3 AND 2 < 1) returns → ______
5. 3 + 2 * 4 = ___ (Assume BODMAS)
INPUT VARIABLE
OUTPUT VARIABLE
OUTPUT “MESSAGE”,variable, “MESSAGE”,……
Age Calculator-
DECLARE age: __________
DECLARE birth_year:_____________
DECLARE _____________ : ____________
INPUT birth_year
current_year ← 2025
age ← _______ - _______
OUTPUT "Your age is", _______
Q: What will this code output if name ← "Zeba"?
OUTPUT "Welcome", name, "to the class."
A. Welcome Zeba to the class.
B. "Welcome" + name + "to the class."
C. Welcome, name, to the class.
D. Error
SELECTION
IF condition_1 THEN CASE OF variable:
statements_1 Value_1: Statements
ELSE Value_2: Statements
IF condition_2 THEN Value_3: Statements
statements_2 …..
ELSE OTHERWISE: Statements
statements_3 ENDCASE
ENDIF **OTHERWISE IS EQUIVALENT TO LAST ELSE OF
ENDIF NESTED IF-ELSE BLOCK.**
Example:
INPUT Day CASE OF Day:
IF Day=6 THEN 6: OUTPUT “Saturday”
OUTPUT “Saturday” 7: OUTPUT “Sunday”
ELSE OTHERWISE: OUTPUT “School_Day”
IF Day=7 THEN ENDCASE
OUTPUT “Sunday”
ELSE
OUTPUT “School_Day”
ENDIF
ENDIF
Write a pseudocode to determine the discount a customer gets based on their electricity usage in units.
If units < 100 → "No Discount"
If units between 100 and 200 → "5% Discount"
If units > 200 → "10% Discount"
INPUT _______________ CASE OF____________:
IF units < ____________________ THEN _______: OUTPUT "No Discount"
OUTPUT "No Discount" _______: OUTPUT "5% Discount"
ELSE OTHERWISE: __________________
IF units <= ___________THEN ENDCASE
OUTPUT "_________________"
ELSE
__________________________
ENDIF
ENDIF
TRY OUT YOURSELF:
Based on a student's grade, print the corresponding message.
A → “Outstanding”
B → “Very Good”
C → “Good”
Any other grade → “Invalid Grade”
IF-ELSE Code: CASE OF Code:
ITERATION
PRE-CONDITION LOOP POST-CONDITION LOOP COUNT-CONTROLLED LOOP
WHILE condition_entry DO REPEAT FOR variable ← start TO stop STEP jump
Statements Statements Statements
ENDWHILE UNTIL condition_EXIT NEXT variable
Question: Display “ZEBA” 5 Times.
count ←0 count ←0 FOR count ← 0 TO 4 STEP 1
WHILE count<5 DO REPEAT OUTPUT “ZEBA”
OUTPUT “ZEBA” OUTPUT “ZEBA” NEXT count
count ← count +1 count ← count +1
ENDWHILE UNTIL count>=5
Note: WHILE and UNTIL condition are opposites of each other.
Question 1: Question 2: Question 3:
Write pseudocode to find the sum Write pseudocode to find the sum of Write pseudocode to find the sum of the
of the first 5 even numbers starting the first 5 even numbers starting from first 5 even numbers starting from 2 (i.e., 2,
from 2 (i.e., 2, 4, 6, 8, 10) using a 2 (i.e., 2, 4, 6, 8, 10) using a 4, 6, 8, 10) using a FOR loop.
WHILE loop. REPEAT UNTIL loop.
num ← 2 num ← 2
sum←______
sum ← ______ sum ← ______
FOR _____← 2 TO ___ STEP ___
count ← ______ count ← ______
____ ← sum + ___
WHILE count < ___ DO REPEAT
____ ← sum + ___ NEXT _____
____ ← sum + ___
num ← num + ___ OUTPUT ______
num ← num + ___
count ← count + ___
count ← count + ___
UNTIL __________________
ENDWHILE
OUTPUT ______
OUTPUT ______
Write pseudocode to loop from 1 to 10.
If the number is even, add it to even_sum.
Else, add it to odd_sum.
Display both sums at the end.
num ← 1 num ← 1 even_sum ← 0
even_sum ← ______ even_sum ← ______ odd_sum ← 0
odd_sum ← ______ odd_sum ← ______ FOR num ← 1 TO ___ STEP ___
WHILE num <= ___ DO REPEAT IF ___________ <> 0 THEN
IF num MOD 2 = 0 THEN IF ________= 0 THEN _______________________
even_sum ← ______ even_sum ← ______ ELSE
ELSE ELSE ________________________
odd_sum ← ______ odd_sum ← ______ ENDIF
ENDIF ENDIF NEXT num
num ← num + ___ num ← num + ___ OUTPUT "Even Sum = ", ______
ENDWHILE UNTIL num > ___ OUTPUT "Odd Sum = ", _______
OUTPUT "Even Sum = ", ______ OUTPUT "Even Sum = ", ______
OUTPUT "Odd Sum = ", ______ OUTPUT "Odd Sum = ", ______
Write pseudocode to loop from 1 to 15.
If a number is divisible by 3, add it to multiple_sum.
Otherwise, add it to non_multiple_sum.
At the end, display both sums.
WHILE Code: REPEAT…UNTIL Code: FOR Code:
Write pseudocode to keep asking the user for a password Write pseudocode to keep asking the user for a password
until its length is at least 8 characters using WHILE. until its length is at least 8 characters using
REPEAT…UNTIL.
INPUT ___________ INPUT _______________
WHILE LENGTH(password) < _____DO REPEAT
OUTPUT ___________________ OUTPUT ___________________
_________ _____________ _________ _____________
ENDWHILE UNTIL _____________________.
OUTPUT "Password accepted" OUTPUT "Password accepted"
Prompt the user to enter a number. Keep repeating the prompt until the number is between 1 and 100 (inclusive).
Write equivalent REPEAT….UNTIL Code-
________ __________
WHILE number < ___ OR number > ___ DO
OUTPUT "Invalid input. Enter a number between 1 and
100:"
INPUT number
ENDWHILE
OUTPUT "Valid number entered"
Ask the user to enter 5 test scores. If any score is invalid (i.e., not between 0 and 100), prompt them to re-enter that
specific score again (repeat that iteration).
total ← ______
FOR i ← 1 TO _____ STEP 1
INPUT_____
WHILE score < ___ OR score > ___ DO
OUTPUT "Invalid score. Enter a value between 0 and 100:"
INPUT _______
ENDWHILE
_______ ← ______ + score
NEXT i
OUTPUT "Total Score = ",_______
Ask the user to enter the prices of 5 products.
If a price is invalid (i.e., less than 1 or greater than 10,000), prompt the user to re-enter that price.
At the end, calculate and display the total price of all valid entries.
Code:
TRY OUT YOURSELF-
You are building a smart shopping system for 5 products.
1. Ask the user to enter product name (string), price (real), and quantity (integer) for 5 products.
2. Validate each price:
o Must be between 1 and 10,000
3. Validate each quantity:
o Must be a positive integer
4. Calculate and display the total amount per product
5. At the end, calculate the grand total
6. Based on the grand total, apply discount rules:
o If total < 500 → "No Discount"
o If total between 500 and 1000 → "5% Discount"
o If total > 1000 → "10% Discount"
7. Display final payable amount after discount
8. Include IF-ELSE and CASE logic to display a message:
o A: "Top Buyer"
o B: "Regular Buyer"
o C: "New Buyer"
o Other: "Invalid Code"