Page 76 - 2502_Pakistan-kifayat_C-8
P. 76
CONSTANTS AND VARIABLES
There are many situations where we need to keep track of the increase or decrease in the count of
things, such as a player’s score, the number of lives left in a game, or how many times a loop has run.
For example, in a quiz game, the total number of questions is always 10. This number never changes.
The player’s score starts at 0 and increases with each correct answer. This score can change.
Constants
A constant is a value that does not change while the program runs. A constant is a fixed value. For
example, the number of days in a week is always 7.
CONSTANT days_in_week = 7
Variables
A variable is used to store information during a program’s execution. It can change its value while the
program runs. For example, a score that increases in a game.
Set score = 0
Set score = score + 10
In pseudocode, Set is used to assign a value to a variable. It means you are storing or giving a value to
that variable.
Difference between constants and variables
Type Description Example
Constants Fixed values that do not change. CONSTANT PI = 3.14
Variables It can change during the execution of program. Set score =10
CONDITIONAL STATEMENTS
Conditional statements are used in programming to make decisions. They allow a program to choose
between different actions based on whether a condition is true or false.
Start
IF Statement
The IF statement runs some code only if the condition is true.
The syntax of the IF statement is as follows: Conditional False
Expression
if conditional expression then
Body of if
For example, If the age is 13: True
Start
Body of if
Input number age
If age > 12 then
Print "Teenager"
Stop
End
The pseudocode checks if age is greater than 12. If true, it shows "Teenager".
74 Premium Edition-VIII

