2.2 Problem solving and programming Flashcards

1
Q

Why are programming constructs used?

A

to represent the programs control flow

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

Give three constructs of structured programming.

A

Sequence, branching and iteration

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

What is the programming construct of sequence?

A

the code is executed line-by line, from top to bottom

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

What is the programming construct of Branching/selection ?

A

the block of code is run if a specific condition is met.

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

What is the programming construct of iteration?

A

the block of code is executed a certain number of times or while a condition is met.

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

What are the two types of iteration?

A

Count- controlled and condition controlled

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

What is Count-controlled iteration?

A

the iteration is repeated a give number of times

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

What is Condition-controlled

A

the iteration continues until a specific condition is met

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

What is Recursion?

A

a programming construct in which a subroutine calls itself during its execution until a stopping condition is met.

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

What are the advantages of Recursion?

A

reduces lines of code and is less prone to errors

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

What are the disadvantages of Recursion?

A

its an inefficient use of memory (can cause a stack over) and is difficult to trace

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

What are the two types of error?

A

Logic and syntax errors

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

What is a Logic error?

A

when the program works, but not in the intended way, produce an unexpected output

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

What is a Syntax error?

A

when the rules of the programming language have been broken

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

What is a Scope?

A

it 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
16
Q

What are Local variables?

A

variables that can only be accessed within the block of code in which they were defined.

17
Q

Why are local variables used?

A

to ensure subroutines are self-contained

18
Q

What are Global variables?

A

Variables that can be accessed across the whole program

19
Q

What are the drawbacks to using global variables?

A

they can be unintentionally over written and require more memory as they aren’t deleted.

20
Q

What happens if a local variable has the same name as a global variable?

A

the local variable will take precedence

21
Q

What is Modular programming?

A

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

22
Q

What is a benefit of a modular design?

A

it makes it easier to divide tasks between a team as each component can be dealt with individually. the components are also more reusable.

23
Q

What is the top-down approach (stepwise refinement)?

A

the problem is continually broken down into sub-problems, each can be represented as an individual, self- contained blackbox which performs a certain task

24
Q

What are functions and procedures?

A

named blocks of code that perform a specific task

25
Q

Whats the difference between functions and procedures?

A

procedures do not have to return a value; functions always return a value

26
Q

What is a parameter?

A

a value that is passed into a subroutine

27
Q

What two ways can a parameter be passed into a subroutine?

A

by value or by reference

28
Q
A