Programming Techniques Flashcards

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

Algorithm

A

A set of step-by-step instructions to solve a problem

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

Three programming constructs

A

Sequences, selection, iteration

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

Sequences

A

A series of logical steps that perform an action

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

Selection (branching)

A

A decision or question that changes the direction of a program depending on the outcome

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

Examples of sequences

A

Print statements and variable initialisation

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

Examples of selections

A

If and case statements

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

Iteration

A

Iteration is the process of repeating sections of a program

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

Three types of iteration

A

Infinite loops, count-controlled loops, condition-controlled loops

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

Infinite loops

A

Repeats until the user terminates the program or it crashes

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

Count-controlled loops

A

Used to make the program repeat the same thing a specific number of times

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

Example of count-controlled loop

A

FOR loop

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

Condition-controlled loops

A

Repeated based on a certain condition

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

Example of condition-controlled loop

A

WHILE loop

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

DO WHILE loop

A

Condition-controlled loop - iteration occurs indefinitely as long as specified condition is met

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

REPEAT UNTIL loop

A

Condition-controlled loop - iteration occurs indefinitely until specified condition is met

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

Scope

A

The area where a function or variable is visible and accessible to other code

17
Q

Global variable

A

Declared outside any function and can be accessed throughout all of the program

18
Q

Local variable

A

Declared inside a function and can only be accessed inside of that function

19
Q

Why are local variables better to use than global variables?

A

Unnecessary use of global variables can make programs hard to test,debug and maintain