8.1 Programming Concepts Flashcards
State the 5 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
Describe the conditional statement CASE … OF … OTHERWISE … ENDCASE and give a reason why you would use it
Description: A statement that allows for multiple selections/deals with many possible outcomes
Reason: To simplify pseudocode and make it easier to read
Describe the pseudocode statement IF … THEN … ELSE … ENDIF
A conditional statement …
… with different outcomes for true and false
Convert the following C# code into pseudocode
Console.Write(“Enter item: “);
item = Console.ReadLine();
OUTPUT “Enter item: “
INPUT item
Convert the following C# code into pseudocode
Console.Write(“Enter price:”);
price = double.Parse(Console.ReadLine());
OUTPUT “Enter price:”
INPUT price
Which datatype should be used to store the following data
Address
Height (m)
Grade (A to F)
Price
Age
Married
Telephone Number
Address: STRING
Height (m): REAL
Grade (A to F): CHAR
Price: REAL
Age: INTEGER
Married: BOOLEAN
Telephone Number: STRING
What are the 3 loop (iteration) structures you need to know?
FOR … TO … NEXT
WHILE … DO … ENDWHILE
REPEAT … UNTIL
Describe the FOR … TO … NEXT loop structure and state when you would you it
- A loop that will iterate a set number of times.
- Used when you know how many times you want to iterate.
Write an algorithm that asks the user to enter a score (integer). If it is below 50 it should output “Fail”. If it is 50 to 64 it should ouput “Pass”. If it is 65 or above it should output “Merit”

Write an algorithm using a case statement that asks the user to enter an integer. If the number entered is 1 or 2 it should output “one” or “two” respectively. Otherwise it should output “unknown”.

Write an algorithm that totals the numbers 1 to 100 and outputs the total.

Write an algorithm using pseudocode to:
- input a positive integer
- use this value to set up how many other numbers are to be input
- input these numbers
- calculate and output the average of these numbers

Describe the WHILE … DO … ENDWHILE loop structure and state when you would use it
- A condition-controlled loop.
- Condition is checked at the start of the loop.
- The code inside the loop may therefore not execute.
- Used when you do not know how many times to iterate.
Describe the REPEAT … UNTIL loop structure and state when you would you it
- A condition-controlled loop.
- Condition is checked at the end of the loop.
- The code inside the loop will always execute at least once.
- Used when you do not know how many times to iterate.
Write an algorithm that asks the user to guess a name. It should keep asking the user until the name Turing is entered.
You must use a WHILE … DO … ENDWHILE loop

Write an algorithm that asks the user to guess a password. It should keep asking the user until the name password 1L0v3Marm1t3 is entered.
You must use a REPEAT … UNTIL loop

What makes a maintainable program?
- Meaningful identifier names for variables, constants, arrays, procedures and functions
- The problem is broken down into appropriate subroutines (functions and procedures)
- It should be fully commented to explain/document the code for yourself and others