Section 1 - Fundamentals of Programming Flashcards

(39 cards)

1
Q

What is an algorithm?

A

A set of rules/a sequence of steps you can follow to solve a problem. They have inputs, processing and outputs.

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

What is psuedocode?

A

The midpoint between a natural language and a programming languages. There are no concrete rules or syntax with multiple ways of writing the same statement.

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

What does the trunc function do?

A

Rounds a real number down to the nearest whole number

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

What does the div function do?

A

Floor division

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

What does the mod function do?

A

Gives the remainder

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

What are variables?

A

Identifiers given to memory locations whose content will change during the course of the program

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

What are constants?

A

A type of variable where the value never changes as the program is being run

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

What is the advantage of using constants?

A
  • There is no chance a programmer accidentally changes it’s value during the program
  • It is more readable than using values
  • If you change the value of the constant you don’t have to manually change it on every line it appears
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the 3 programming constructs?

A
  • Sequence
  • Selection
  • Iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is sequence?

A

2 or more statements following one after the other

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

What is selection?

A

A statement used to select which statement will be executed next, depending on some condition

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

What are relational operators used for?

A

Formulating the condition for selection

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

What is the CASE statement?

A

An alternative structure to the IF statement that is useful when there is a choice between several alternatives

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

What is the XOR operator?

A

Exclusive OR, i.e either a or b but not both

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

What is an iterative statement?

A

A statement causing the code to perform a loop, repeating a number of statements

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

What is indefinite iteration?

A

Where the iteration continues until a specified condition is met

17
Q

What is definite iteration?

A

Where the number of loops is decided in advance

18
Q

What is the difference between a WHILE loop and a REPEAT UNTIL loop?

A

In a while loop the condition is checked at the start so will iterate 0 or more times, whilst a REPEAT UNTIL loop is checked at the end so will always iterate at least once

19
Q

What is a data structure?

A

A collection of elementary data types with built-in methods to facilitate processing in some way

20
Q

What is an array?

A

A finite, ordered set of elements of the same data type. Finite means there is a set number of elements in the array whilst ordered implies there is a first, second, third, etc

21
Q

How can you reference each element of an array?

A

By using an index (usually starting at 0)

22
Q

What is a tuple?

A

An ordered list of elements

23
Q

What is a n-dimensional array?

A

A set of elements of the same data type, indexed by a tuple of n integers

24
Q

What is a subroutine?

A

A named block of code which performs a specific task within a program

25
What are the 2 common types of subroutines?
- Functions - Procedures
26
What is the difference between functions and procedures?
Functions always assign a return value to a variable and is called like an input, where as a procedure is called by just writings its identifier and does not need to return a value
27
How can you pass parameters into a subroutine?
- By value, meaning changing the parameter inside the subroutine will not affect its value in the rest of the code - By reference, where the address of the parameter and not its value is passed into the subroutine and therefore any changes will reflect in the rest of the code
28
What are global variables?
The default state for a variable, able to be used anywhere in the program
29
What are local variables?
Variables declared in a subroutine that cannot be accessed outside of it. A local variable can share a name with global variables or other local variables inside different subroutines
30
Why should you declare local variables?
It makes each subroutine is self-contained and independent of global variables.
31
What is modular programming?
Where a program is broken into different subroutines
32
What are the advantages of modular programming?
- They are small enough to be understandable as a unit of code, making it easier to understand, debug and maintain them - They can be tested independently, reducing the time needed to make a program - It can be reused in different programs or different parts of the same program - When working in a group each programmer can handle 1 subroutine at a time
33
What is required in order to store data permanently?
It must be stored in a file or disk
34
What is a file?
Structured data, usually consisting of many records
35
What is a record?
A data structure containing a number of fields, each holding an item of data
36
How can you overwrite data in an existing file?
You open the record for both reading and writing in order to search through the record before writing a new record in place
37
What is the advantage of a binary file?
It can contain records with different types of data types in each field
38
What is exception handling?
The process of dealing with unexpected conditions in your program
39
What are common errors that can cause a program to crash?
- Trying to read a non-existent file - Trying to convert a non-numeric string to an integer or real - Trying to perform calculations with a non-numeric value - Division by 0