S2 - Programming (Done) Flashcards

1
Q

What are the main data types ?

A

Integer(INT), real(or float)(REAL), boolean(BOOL), character(CHAR), string(STRING).

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

How much memory does an integer take up ?

A

2 bytes or 4 bytes.

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

How much memory does an real take up ?

A

4 bytes or 8 bytes.

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

How much memory does an boolean take up ?

A

1 bit is needed but 1 byte usually used.

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

How much memory does an character take up ?

A

1 byte.

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

How much memory does an string take up ?

A

1 byte for every character in the string.

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

How do you change from a string to an integer in pseudo-code ?

A

STRING_TO_INT( ‘1’ )

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

How do you change from an integer to an string in pseudo-code ?

A

INT_TO_STRING( 1 )

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

How do you change from a string to a real in pseudo-code ?

A

STRING_TO_REAL( ‘1’ )

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

How do you change from a real to a string in pseudo-code ?

A

REAL_TO_STRING( 1.0 )

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

What are the basic arithmetic operators ?

A

Addition, subtraction, multiplication, division, integer division(DIV) - only works with integers and remainder(MOD or %) - only works with integers.

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

What is a constant ?

A

Something that can’t be changed in the program, trying to will result in an error. They’re assigned a value at design time.

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

What is a variable ?

A

Something that can be changed, meaning that a variables value can be changed at any point throughout the program making them much more useful than constants.

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

What does the string manipulation LEN(string) do ?

A

Returns the number of characters in that string.

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

What does the string manipulation POSITION(string, character) do ?

A

Returns the position of the occurrence of a certain character in a given string.

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

What does the string manipulation SUBSTRING(x, y, string) do ?

A

Extracts a substring from the original string starting at position x and finishing at position y.

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

What is a nested IF statement ?

A

An IF statement inside another IF statement, allowing you to check more conditions once you’ve established that the previous condition is true or false.

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

What are ELSE-IF statements ?

A

Used to check multiple conditions and give different outputs depending on which condition is true, different from nested IF statements as they only check more conditions if the first one is false.

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

What is a CASE statement ?

A

They check the value of a variable, used when you want the program to perform different actions for different values of the same variable.

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

What is a repeat-until loop ?

A

Controlled by a condition at the end, keeps going until condition is true, always run the code inside them at least once and you get an infinite loop if condition is never true.

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

What is a while loop ?

A

Controlled by a condition at the start, keeps going while condition is true, never run the code inside if condition is initially false and you get an infinite loop if the condition is always true.

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

What is a do-while loop ?

A

Controlled by a condition at the end, keeps going while condition is true, always run the code inside them at least once and you get an infinite loop if the condition is always true.

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

What is a FOR loop ?

A

An example of a count controlled loop, repeating the code inside them a fixed number of times.

24
Q

What is a nested iteration statement ?

A

Where the program contains a loop within another loop, where every time the outer loop repeats the inner loop completes a full set of iterations.

25
Q

What are the three boolean operators you need ?

A

AND, OR and NOT.

26
Q

In what order are boolean operations carried out ?

A

Brackets, NOT, AND then OR.

27
Q

What is a potential use of boolean operators ?

A

In selection and iteration statements to check multiple conditions.

28
Q

How can random integers be generated in pseudo code ?

A

RANDOM_INT(x, y)

29
Q

When would you use random number functions ?

A

When you don’t want the program to run the same thing every time.

30
Q

How can you generate multiple random numbers in one command ?

A

Nest the function to create a random number within a FOR loop to get a set amount of numbers.

31
Q

What is an array ?

A

A data structure that can store groups of data of the same type within one variable name.

32
Q

What are the bits of data in an array called ?

A

Elements, they can be accessed using its position/index in the array.

33
Q

What are one-dimensional arrays ?

A

Essentially just lists.

34
Q

How can you retrieve elements form an array ?

A

Use the name of the array followed by the position of the element you want enclose by square brackets.

35
Q

Is it possible to change a pre-defined element within an array? How?

A

Yes, reassigning the array position to a different value (array[0]

36
Q

What is a two-dimensional array ?

A

It’s like a list of lists, a list of items where each item is its own smaller list.

37
Q

How can you find a single element in a two-dimensional array ?

A

In a similar way to one-dimensional arrays - do the array name followed by the element in the initial list in square brackets, and then the element within the secondary list also in square brackets.

38
Q

What is a record ?

A

A type of data structure, meaning it’s used to store a collection of data - this data can be of different types.

39
Q

What are items in a record called ?

A

A field - each field is given a data type and a field name when the record is created - field name used to help describe the data stored in the field of that record.

40
Q

Are records able to be edited after creation ?

A

No, they’re fixed in length - meaning you can’t add extra fields after creation, however you can edit preexisting fields.

41
Q

How do you create a record ?

A

First you create the record structure with names and data types, and then you assign the structure to variables along with data for each field.

42
Q

What happens to data stored in arrays and records when the program is off ?

A

They’re useful data stores when the program is running but data will be lost when the program is closed.

43
Q

How can data be stored permanently outside of programs ?

A

By writing the data onto an external file.

44
Q

How do you open an external file ?

A

Using an OPEN() command and assigning the file to a variable.

45
Q

How do you close an external file ?

A

Using the CLOSE() command - if you don’t close the file it may remain locked and prevent others form editing it.

46
Q

How can you write in a file you’ve opened ?

A

Using WRITE() or WRITELINE() commands - both taking two perameters, the variable storing the file and the text you want to write.

47
Q

How can you read text from a file ?

A

Using READ() or READLINE() commands

48
Q

Is it possible to return when the ‘cursor’ is at the end of the file ?

A

Yes, by using the ENDOFFILE() command which will return true if the ‘cursor’ is at the end of the file.

49
Q

What is the ‘cursor’ in file handling ?

A

As you read from or write to the file the program keeps its place in the file - this place being the ‘cursor’.

50
Q

What are subroutines ?

A

Sets of instructions stored under one name - this name can be recalled within a program do to all the instructions within it.

51
Q

What changes between a subroutine being a function or a procedure ?

A

A function always returns a value, while a procedure does not.

52
Q

Why are subroutines useful ?

A

They give the program more structure and readability and cut down on the amount of code needed.

53
Q

What are perameters ?

A

Special variables used to pass values into a subroutine.

54
Q

What are local variables ?

A

Variables that can only be used within the structure they’re declared in - they have a local scope.

55
Q

What are global variables ?

A

Variables that can be used at any time after their declaration - having a global scope.

56
Q

What are the advantages of local variables ?

A

Scope only extends to subroutine they’re declared in - so not affected by and don’t affect anything outside the subroutine. Also doesn’t matter if the same variable name is used as a local variable elsewhere as it will be redefined.