2.2 Programming Concepts Flashcards

1
Q

State the 5 programming 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

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.
24
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.
25
Q

What is an array?

A
  • Collection of variables of the same data type
  • Referred to by a single name (identifier)
  • Each element is accessed by an index (position)
  • Often called a data structure
26
Q

What are the advantages of an array?

A

+ can store multiple values under a single identifier
+ reduces the number of variables
+ can use iteration to loop through an array
+ allows for more efficient programming

27
Q

What is a subroutine?

A

A subroutine is a block of code that is given a name.

28
Q

State 2 types of subroutine

A

Function and Procedure

29
Q

What is the difference between a function and a procedure

A

Function – A subroutine that always returns a value.
Procedure – A subroutine that may or may not return a value.

30
Q

What is a library routine?

A

Library routine – A prewritten subroutine to carry out common tasks (it is available for immediate use)

31
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
32
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
33
Q

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

A
34
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
35
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
36
Q

Write an algorithm that asks the user to enter 10 names and stores them into an array called names.

It should then output the names in reverse order

A
37
Q

Write an algorithm that searches through an array of integers named nums to find the highest value and the average of all of the numbers stored. The array stores 100 numbers.

Your program should then output the highest value.

A