Programming Techniques Flashcards

Sequence, iteration, branching Global and Local Variables Recursive functions Modularity, functions and procedures Features of an IDE

1
Q

Define Sequence

A

Code that is executed line-by-line, from top to bottom

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

Define Branching

A

A certain block of code that is run if a specific condition is met, using IF
statements

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

What is branching similar to?

A

Selection

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

Define Iteration

A

A block of code that is executed a certain number of times or while a condition is
met. Iteration uses FOR, WHILE or REPEAT UNTIL loops

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

Define count controlled iteration

A

Iteration is repeated a given number of times

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

Define condition controlled iteration

A

Iteration continues until a given condition is met

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

Define recursion

A

Recursion is a programming construct in which a subroutine
calls itself during its execution

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

When does the recursion end?

A

When the stopping condition is met

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

What also produces the same result as recursion?

A

Iteration

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

Give an advantage of recursion

A

The advantage of using recursion for certain problems is that
they can be represented in fewer lines of code, which makes them less prone to errors

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

Give a disadvantage of recursion

A

Inefficient use of
memory. If the subroutine calls itself too many times, there is a danger of a stack overflow,
which is when the call stack runs out of memory. This would cause the program to crash. Another problem with recursion is that it is difficult to trace,
especially with more and more function calls

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

What type of recursion uses less stack space?

A

Tail recursion

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

Define scope

A

Refers to the section of
code in which the variable is available

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

Define local variable

A

A variable with limited scope which means that they
can only be accessed within the block of code in which they
were defined

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

Give an advantage of using local variables

A

Multiple local variables with the same name can
exist in different subroutines and will remain unaffected by
each other. Therefore variables cannot be accidentally overwritten

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

Define global variable

A

A variable that can be accessed across the whole program

17
Q

Give an advantage of using global variables

A

Variables can be used in multiple parts of the program

18
Q

Define modular programming

A

Modular programming is a programming technique used to split large, complex programs
into smaller, self-contained modules

19
Q

Give a disadvantage of using global variables

A

They can be
unintentionally overwritten and edited. As global variables are not deleted until the
program terminates, they require more memory than local variables which are deleted
once the subroutine has been completed

20
Q

Why is modular programming essential?

A

Modularity is essential to making a problem easier to
understand and approach

21
Q

Give an advantage of modular programming

A

Each
component can be dealt with individually. This improves the reusability of components, as
once a module has been tested, it can be reused with confidence.

22
Q

Define the top-down approach

A

The problem is continually
broken down into sub-problems, until each can be
represented as an individual, self-contained black-box which
performs a certain task.

23
Q

Define a procedure

A

Procedures can return multiple values and are typically
given data as parameters for manipulation

24
Q

Define a function

A

A function
must return one, single value and
commonly make use of local variables

25
Q

What does IDE stand for?

A

Integrated Development Environment

26
Q

What does stepping do?

A

This allows you to monitor the effect of each individual line of code by
executing a single line at a time.

27
Q

What does variable watch do?

A

Sometimes used to pinpoint errors, this is a useful feature to observe how
the contents of a variable change in real-time through the execution of a
program

28
Q

What does breakpoint do?

A

IDEs allow users to set a point in the program at which the program will stop.
This can either be based on a condition or set to occur at a specific line. This
can help to pinpoint where an error is occurring

29
Q

What is the source code editor?

A

The editor aims to make the coding process easier by providing features
such as autocompletion of words, indentation, syntax highlighting and
automatic bracket completion.

30
Q

What debugging tools are there?

A

Some IDEs also provide run-time detection of errors with a guide as to where in the code they are likely to have occurred through line numbers and
highlighting