Programming Techniques Flashcards

1
Q

What is a sequence?

A

A control structure in which a set of instructions is each executed once, in order in which they are written

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

What is selection? (Branching)

A

A control structure in which an option of statements is provided and a condition is used to decide which (if any) statements should be executed

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

What are some examples of selection?

A
  • If statements = Is a condition true or false? Else statements used if condition is not met, Else If statements used if there are alternate outcomes and End If used to end the statement
  • Case statement = uses variable instead of condition to determine which instructions should be executed. Replacement for long if/else statements whose condition depend on same variable. End Select used to end statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is iteration?

A

Control structure in which a group of statements is executed repeatedly (Loops)

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

What are condition controlled loops?

A

-Condition that allows us to exit the loop once a particular condition has been met

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

What is a while loop?

A

-While loop = condition tested before loop, if condition = false the loop will be ignored. If true the loop will be executed until the condition becomes false. Condition tested on each iteration

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

What is a Do loop?

A
  • Can be in the form of Do…While, Do..Until, Do while and Do until.
  • In Do…While and Do…until the code is executed at least once and the condition is tested at end of loop. Do…While loops as long as condition is met and Do…Until loops until condition is met
  • Do While is the same as a while loop
  • Do until is the same as a while loop except it will loop until condition is met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are for loops?

A
  • Count controlled loops that will iterate a specific number of times before exiting
  • Use variable to determine how many times the instructions within a loop should execute
  • Variable must have start and end value for the loop to be able to function properly.
  • With each iteration the variable is Incremented. This continues until the variable reaches the end value and the loop exits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is variable Scope?

A

-Range of statements for which it is valid

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

What is a local variable? +/-?

A

-Declared in a sub area of the program code, may be in a function or procedure. Values in these variables will only be accessible from the sub program they are declared in. Should be used where ever possible
-Eg; A variable declared within a for loop can only be accessed whilst in that loop. Once the loop has ended the variable can no longer be accessed. (Local variable)
+Only used when sub program is called so main memory usage is limited
-Limited scope

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

What is a global variable? +/-

A

-Declared in the root area of the program code (usually the beginning)
-Values stored in these variables will be accessible from any area of the code
+Can be accessed anywhere
-Sit and take up main memory
-Create complications when integrating modules as different modules may have the same global variables but with different values

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

What are functions?

A
  • Subroutine that executes its statements and returns a single value
  • Black boxes, we have them and know what they do but we don’t care how they do it
  • Can be reused or called whenever it is needed
  • Made up of all the stuff that’s in a subroutine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are procedures?

A
  • Subroutines that do not return a value

- Act independently of the rest of the program and do not usually return a value to the procedure call

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

What is a parameter?

A
  • An item of data that is given to a procedure or function
  • Written in brackets after the name of the procedure or function
  • Can be passed by reference or value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are parameters passed by value?

A
  • The original data is not changed
  • A copy of the original is passed to function/procedure
  • Any changes made are lost as soon as the function is no longer in use
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is passing by reference?

A
  • Original data is changed
  • Pointer to the address in memory of the original data is passed to the function/procedure being called
  • The changes made stay even when function/procedure is no longer in use
18
Q

What is an IDE?

A
  • Combines all of the tool you need to write, error-check, build, run and debug your source code, inside a single application
  • includes; code editor, automated build process and debugger
19
Q

What does the code editor do?

A
  • Checks syntax as you type
  • Auto-completed variables/producers names/brackets etc
  • Auto formats (code indentations)
  • Auto colours code to highlight keywords, strings objects etc
20
Q

What is the automated build process?

A

-Performs syntax checking, then complies and links your code, and generates an executable program with one click

21
Q

What does the debugger do?

A
  • Allows you to check your code for errors during execution. Includes;
  • Breakpoints = set at specific points in code, program stops when it reaches one allowing a programmer to inspect the values of variables, step through the code one line at a time or jump to the next point
  • crash dump = when program crashes you can inspect state of variables at point in which error occurred
  • Display stack contents = during execution, current contents of the stack can be viewed to allow programmer to trace the sequence though subroutines/functions that have been called
22
Q

What are subroutines?

A
  • Set of instructions that perform a specific task as part of a larger program.
  • Main program contains instructions to call the subroutine
  • When called the program transfers control to the subroutines and the instructions within it are executed. Control is transferred back when complete
  • Should have identifier, parameters, instructions and output(s)
23
Q

What is recursion?

A
  • where a procedure in a function calls itself
  • important to make sure that there is an end point in order to avoid an endless loop
  • example of divide and conquer; problem is broken down into small component parts of the same type and then solved in a simple way
24
Q

What does it mean to think concurrently?

A
  • tackling different parts of a problem simultaneously
  • computers do this with the use of multiple cores
  • can also be applied to human planning. Gang charts used to plan who does what