2.2 Programming Concepts Flashcards
State the 5 programming data types you need to know
INTEGER
STRING
REAL
CHAR
BOOLEAN
Describe, giving an example, the data type INTEGER
Stores a whole number e.g. 3, 45,‐453
Describe, giving an example, the data type STRING
Stores zero or more sequence of characters e.g. “Bob”, “44-0151”, “:)”
Describe, giving an example, the data type REAL
Stores integers and numbers with a decimal part e.g. 3 , 3.2, -9.11
Describe, giving an example, the data type CHAR
Stores a single character (a letter, digit, punctuation mark or symbol) e.g. ‘a’, ‘#’, ‘9’
Describe, giving an example, the data type BOOLEAN
Stores only 2 possible values e.e. true (1) or false (0)
What is a variable?
A variable is named memory location that can store a value.
The value can change whilst the program is running.
What is a constant?
A constant is a named value.
The value cannot change whilst the program is running.
What are the advantages of constants?
The code will be easier to read and understand (because the constant’s identifier will be used instead of a number)
When its value changes, you only have to edit it in one place.
The value cannot be accidentally changed during the running of the program.
Explain the Pseudocode key words MOD and DIV and give an example
DIV = whole number part of division
17 DIV 5 = 3
MOD = the remainder part of division
17 MOD 5 = 2
Describe, giving an example in pseudocode, the term “counting”
Counting is used to count the number of items in a list.
Count is usually incremented by 1
count ← count + 1
Describe, giving an example in pseudocode, the term “totalling”
Totalling is used to sum a list of numbers.
Each values is added to a running total.
total ← total + value
What is sequencing?
Sequencing is the idea of one statement or instruction being executed one after another
Describe, giving an example in pseudocode, the term “selection”
Selection decides which statements are executed based on a condition e.g.
IF age >= 18 THEN
OUTPUT “You can vote”
ENDIF
What are the 2 types of conditional statement you need to know
IF … THEN … ELSE … ENDIF
CASE … OF … OTHERWISE … ENDCASE