2.2.1 Programming techniques Flashcards

Not including OOP

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the three programming constructs?

A

-sequence
-selection
-iteration

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

What is sequence?

A

-executing instructions one after another

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

What is selection?
Give an e.g

A

-allows a program to change direction depending on the outcome of a condition (boolean expression)
-e.g an IF statement

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

What is iteration?
Give an e.g

A

-repeating sections of code
-could be a FOR loop (a count-controlled loop)
-could be a WHILE, DO…UNTIL or a REPEAT…UNTIL loop (condition controlled loop)

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

What is recursion?

A

-when a subroutine (often a function) calls itself from within its own subroutine

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

What are the three characteristics of a recursive function?

A

-contains a stopping condition (base case)
-the subroutine should call itself for any input value (other than the base case)
-stopping condition should be reachable within a finite number of times

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

Why does a recursive function need these characteristics?

A

-it may call itself indefinitely, resulting in stack overflow

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

What is a local variable?

A

-declared inside a subroutine
-only accessible by that subroutine
-created when the subroutine is called
-destroyed when the subroutine ends

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

What is a global variable?

A

-declared at the top of a program, outside of any subroutine
-accessible throughout the program
-created when the program starts
-destroyed when the program ends

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

What is the problem with using global variables?

A

-can make programs hard to test, debug and maintain
-using global variables is generally considered poor programming practice

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

What is a module? (4)

A

-procedure
-function
-subroutine
-method

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

What is a procedure?

A

-a block of code that takes in zero, one or more parameters and performs a set task

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

What is a function?

A

-a block of code that takes in zero, one or more parameters; performs a set task; and returns a value

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

What is modularity?

A

-The concept of breaking a large program/ problem down into smaller chunks
-each module carries out a single specific task

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

How do you pass data into a subroutine?

A

-by value
-by reference

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

What is an IDE?

A

A program that provides a set of tools and related functionality designed to maximise a programmers productivity

17
Q

common IDE features(7):

A

-code editors
-error diagnostics (reports errors)
-runtime environments
-translators
-auto documentation
-syntax highlighting
-autocompletion