Pseudocode Flashcards
Assigning a value to a variable
age ← 15
Taking input
INPUT age
Outputting something
OUTPUT age
If statement
IF(age>21)
THEN
OUTPUT “eligible”
ELSE
OUTPUT “Not eligible”
ENDIF
If statement inside if statement
IF( age>=19)
THEN
OUTPUT “Adult”
ELSE
IF(age>=13)
THEN
OUTPUT “Teen”
ELSE
OUTPUT “Child”
ENDIF
ENDIF
Equal and not equal
not equal - IF(a<>5)
Equal - IF(a=5)
Conditional checking
CASE
INPUT ticketChoice
CASE OF ticketChoice
“Red” : redCount← redCount +1
“Blue” : blueCount ← blueCount +1
ENDCASE
For loop
For i ← 0 TO 10
NEXT i
(Runs 11 times including 10)
while loop
WHILE(a <10)
a ← a+1
ENDWHILE
What do you have to do when declaring variables
Declare data type
Functions
FUNCTION add(a,b) RETURNS INTEGER
c← a+b
RETURN c
ENDFUNCTION
ans← add(5,10)
OUTPUT ans