8.1 Programming Concepts Flashcards

1
Q

State the 5 data types you need to know

A

INTEGER
STRING
REAL
CHAR
BOOLEAN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe, giving an example, the data type INTEGER

A

Stores a whole number e.g. 3, 45,‐453

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe, giving an example, the data type STRING

A

Stores zero or more sequence of characters e.g. “Bob”, “44-0151”, “:)”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe, giving an example, the data type REAL

A

Stores integers and numbers with a decimal part e.g. 3 , 3.2, -9.11

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe, giving an example, the data type CHAR

A

Stores a single character (a letter, digit, punctuation mark or symbol) e.g. ‘a’, ‘#’, ‘9’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe, giving an example, the data type BOOLEAN

A

Stores only 2 possible values e.e. true (1) or false (0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a variable?

A

A variable is named memory location that can store a value.
The value can change whilst the program is running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a constant?

A

A constant is a named value.
The value cannot change whilst the program is running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the advantages of constants?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain the Pseudocode key words MOD and DIV and give an example

A

DIV = whole number part of division
17 DIV 5 = 3

MOD = the remainder part of division
17 MOD 5 = 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe, giving an example in pseudocode, the term “counting”

A

Counting is used to count the number of items in a list.
Count is usually incremented by 1

count ← count + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Describe, giving an example in pseudocode, the term “totalling”

A

Totalling is used to sum a list of numbers.
Each values is added to a running total.

total ← total + value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is sequencing?

A

Sequencing is the idea of one statement or instruction being executed one after another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe, giving an example in pseudocode, the term “selection”

A

Selection decides which statements are executed based on a condition e.g.

IF age >= 18 THEN
OUTPUT “You can vote”
ENDIF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the 2 types of conditional statement you need to know

A

IF … THEN … ELSE … ENDIF
CASE … OF … OTHERWISE … ENDCASE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe the conditional statement CASE … OF … OTHERWISE … ENDCASE and give a reason why you would use it

A

Description: A statement that allows for multiple selections/deals with many possible outcomes
Reason: To simplify pseudocode and make it easier to read

17
Q

Describe the pseudocode statement IF … THEN … ELSE … ENDIF

A

A conditional statement …
… with different outcomes for true and false

18
Q

Convert the following C# code into pseudocode

Console.Write(“Enter item: “);
item = Console.ReadLine();

A

OUTPUT “Enter item: “
INPUT item

19
Q

Convert the following C# code into pseudocode

Console.Write(“Enter price:”);
price = double.Parse(Console.ReadLine());

A

OUTPUT “Enter price:”
INPUT price

20
Q

Which datatype should be used to store the following data

Address
Height (m)
Grade (A to F)
Price
Age
Married
Telephone Number

A

Address: STRING
Height (m): REAL
Grade (A to F): CHAR
Price: REAL
Age: INTEGER
Married: BOOLEAN
Telephone Number: STRING

21
Q

What are the 3 loop (iteration) structures you need to know?

A

FOR … TO … NEXT
WHILE … DO … ENDWHILE
REPEAT … UNTIL

22
Q

Describe the FOR … TO … NEXT loop structure and state when you would you it

A
  • A loop that will iterate a set number of times.
  • Used when you know how many times you want to iterate.
23
Q

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”

A
24
Q

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”.

A
25
Q

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

A
26
Q

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
A
27
Q

Describe the WHILE … DO … ENDWHILE loop structure and state when you would use it

A
  • 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.
28
Q

Describe the REPEAT … UNTIL loop structure and state when you would you it

A
  • 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.
29
Q

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

A
30
Q

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

A
31
Q

What makes a maintainable program?

A
  • 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