7. Programming Flashcards

1
Q

What is an algorithm?

A

A series of steps to solve a problem.

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

In what ways can an algorithm be expressed?

A
  • Structured English
  • Pseudocode
  • Flowchart
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is another name for a flowchart?

A

Flow diagram

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

Describe the process by which a program is developed in terms of planning.

A
  • User requirement
  • Flowchart
  • Pseudocode
  • Actual program code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Remember to revise flowchart shapes.

A

Pg 113 of revision guide.

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

What is a flowchart?

A

A diagram using commonly defined symbols to express an algorithm.

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

What is structured English?

A
  • A way of writing an algorithm in natural language using some basic programming constructs such as IF…THEN…ELSE and loops.
  • More structured than just natural language/prose.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is pseudocode?

A

A way of writing an algorithm that is close to actual programming language, using coding-style constructs such as IF…THEN…ELSE, loops and array notation as appropriate.

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

What is sequence?

A

Where instructions are executed one after another in series.

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

Is an “End if” needed after a selection statement in algorithms?

A

Yes, they are usually used just to be really clear.

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

What is selection?

A

Where the program will execute certain instructions based on conditions. (e.g. “If” statements)

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

Give some examples of selection statements.

A
  • IF…THEN…ELSE

* CASE…OF

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

Why are the different ways of coding a menu system where the user can choose between 3 options?

A
  1. Multiple IF statements
  2. Multiple nested IF statements
  3. CASE…OF statements
    (See Pg 116 of textbook)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a CASE…OF statement?

A

A statement designed for coding multiple choices in a program, such as a menu of several options where the user enters one choice.
(See pg 116 of textbook)

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

What is iteration?

A

Where a program will execute certain instructions zero or more times based on a condition.

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

Remember to revise loops.

A

Pg 117 of textbook

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

Can statements like “If EmailAddress does not contain @” be used in pseudocode?

A

Yes

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

What is indentation and capitalisation in pseudocode like?

A
  • Should be indented like a normal program

* PascalCase format used for item (all words capitalised but no spaces)

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

What is Hungarian notation?

A
  • The convention of prefixing identifiers to indicate what type of object they are. Commonly used with forms. e.g. “txt” and “lst”
  • Conventionally in lowercase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is camel case?

A

The use of capital letters in an identifier to make it more readable. The first word is not capitalised.
e.g. camelCase

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

What is Pascal case?

A

The use of capital letters in an identifier to make it more readable. Especially with variables and procedures.
e.g. PascalCase

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

What is a condition?

A

A Boolean expression that controls an iteration or selection statement.

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

What is a Boolean expression?

A

An expression that is true or false.

e.g. continue=”y”

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

What is a high level programming language?

A

A programming language where programming constructs are written in a way that is close to natural language, instead of in mnemonics or machine code.

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

Give an example of a high level programming language.

A
  • Java
  • C++
  • Visual Basic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is machine code?

A

First generation code - binary instructions where some bits are used to define the operation (opcode) and some bits define the data to be used.

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

What is assembly language?

A

Second generation programming language where instructions are in the form of mnemonics.

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

What is an imperative language?

A

A programming language such as Python or Delphi which uses a sequence of statements to determine how to reach a certain goal or solve a problem.

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

What are mnemonics?

A

Abbreviations representing commands used in assembly language programming.
E.g. LDA, STO, ADX

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

How many assembly languages are there?

A

Many - one for each different processor architecture.

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

Describe the relationship between the language generation system and its link to the hardware.

A

1st and 2nd generation - Language is processor specific

3rd generation - Independent of hardware (portable)

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

Describe the language generation system.

A

1st gen - Machine code - Binary
2nd gen - Assembly language - Mnemonics
3rd gen - High level languages - Statements
(See pg 119 of textbook)

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

Compare machine code with high level languages.

A
MACHINE CODE
• Processor specific
• Designed with hardware in mind
• One-to-one relationship with assembly language
HIGH LEVEL LANGUAGES
• Portable
• Designed with type of problem in mind
• On height level program instruction translated into several machine code instructions

(See Pg 120 of textbook)

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

What must be done before a high level language is run?

A

The program must be translated into machine code.

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

What type of software are translators?

A

System software

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

What are the different types of translator?

A
  • Assemblers

* Compliers and Interpreters

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

What do different translators do?

A
  • Assemblers - Convert assembly language into machine code

* Compilers and Interpreters - Convert a high level programming language into machine code

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

Remember to revise the translator diagram.

A

Pg 120 of textbook

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

What is an interpreter and how does it work?

A

A translator that converts high level languages into machine code one line at a time, checking syntax, converting to machine code and executing the code.

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

What is a compiler and how does it work?

A
  • A translator that converts high level languages into machine code.
  • Works through the whole program (source code) checking the syntax, then converting to machine code and creating the executable object code, which can be saved. The object code is executed, not the source code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

What is source code?

A

The original high level program.

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

What is object code?

A

The executable version of the program after it has been compiled.

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

What is an assembler?

A

The translator that converts assembly language programs into machine code.

44
Q

What are mnemonics?

A

Abbreviations representing commands used in assembly language programming.
e.g. LDA, STO, ADX

45
Q

What are the advantages and disadvantages of the use of compilers in business?

A

ADV
• The object code created can be easily distributed without giving the source code to the customers. This prevents illegal copies being made.
DIS
• Software problems in object code harder to diagnose

46
Q

When are compilers and interpreters used most commonly?

A

Interpreters - In development of a program

Compilers - When distributing a program

47
Q

How often does an interpreter have to translate code?

A

Every time it is run - this makes it slow to run.

48
Q

What are the advantages and disadvantages of interpreters?

A
ADV
• Easy to use in development
DIS
• Slow -> Program has to be translated every time it is run
• Users can see code
49
Q

Compare compilers and interpreters.

A
COMPILER
• Translates while program to produce executable object code
• Computer runs object code
• Faster run time
• Customers can't see source code
• Used for distributed software
INTERPRETER
• Translates and executes one line at a time
• Computer runs source code
• Slower run time
• Customers can see source code
• Used in development
50
Q

Why are constants used (rather than typing out the number)?

A
  • If it needs to be changed, it only has to be changed in one place
  • It might be faster to just write the constant name than to type a long number
  • Code is easier to read and understand
51
Q

What is an identifier?

A

A unique name for something (variable, constant, program, procedure, etc.) within the program.

52
Q

What is a constant?

A

A named value within a program that has a specific value. Its value does not change while the program is running.

53
Q

What does a data type define?

A
  • The type of data that will be stored at the memory location and therefore the operations that can be performed on the data item
  • How much space will be needed for that data item
54
Q

Why are variables usually declared at the start of the program?

A
  • Organisation

* The appropriate memory can be reserved to store the data

55
Q

What is a variable?

A

An identifier associated with a particular memory location, used to store data. Its value may change as the program is run and new values are assigned to it.

56
Q

What is a data type?

A

A formal description of a the type of data being stored in a variable.

57
Q

Can a high level programming language store anything in less than a byte?

A

No

58
Q

What are some common data types?

A
  • Integer
  • Real
  • Char
  • String
  • Boolean
59
Q

What is an integer?

A

Data type for whole numbers.

60
Q

What is a real?

A

Data type for fractional numbers.

61
Q

What is a char?

A

Data type for a single character.

62
Q

What is a string?

A

Data type for text - zero or more characters.

63
Q

What is a Boolean?

A

True or false.

64
Q

What are operations?

A

Actions that can be performed on a variable.

65
Q

How much memory does storing an integer take?

A

2 bytes

66
Q

How much memory does storing a real take?

A

4 bytes

67
Q

How much memory does storing a char take?

A

1 byte

68
Q

How much memory does storing a string take?

A

1 byte per character

69
Q

How much memory does storing a Boolean take?

A

1 byte

70
Q

Is the memory taken by a data type the same with every programming language?

A

No, it can vary from language to language.

71
Q

Remember to revise operations.

A

Pg 124

72
Q

When can DIV and MOD be used?

A

When the numbers are integers.

73
Q

What is DIV?

A

Integer division. It works like normal division, except it returns the whole number of times one number goes into another.
e.g. 13 DIV 3 = 4

74
Q

What is MOD short for?

A

Modulus

75
Q

What does MOD do?

A

Gives the remainder of integer division.

e.g. 13 MOD 3 = 1

76
Q

305 DIV 30 =

A

10

77
Q

305 MOD 30 =

A

5

78
Q

What are the arithmetic operations?

A

Add, subtract, multiply, divide, DIV, MOD

79
Q

What are the comparison operations?

A

=, , <=, >=, <>

80
Q

What are the logical operators?

A

NOT, AND, OR

81
Q

What are Boolean expressions?

A

Expressions that resolve to true or false, such as X <= 20.

82
Q

What operations can be performed on integers?

A
  • Arithmetic operations

* Comparison operations

83
Q

What operations can be performed on reals?

A
  • Arithmetic operations (except DIV and MOD)

* Comparison operations

84
Q

What operations can be performed on Booleans?

A

• Logical operations

85
Q

What is an array?

A

A group of data items of the same data type that use a single identifier. Individual data items are accessed using an subscript.

86
Q

What are the advantages of an array?

A
  • Code is easier to follow, debug and maintain

* A group of data can easily be processed by a FOR loop

87
Q

What is syntax?

A

A set of rules that defines how program statements must be written in order for the translator to understand them.

88
Q

What is a syntax error?

A

An error in the format of the program statements, such as a missing semicolon or keywords spelt incorrectly.

89
Q

What is a logic error?

A

An error in the algorithm that means the outcome is not as expected, even though the program will run.

90
Q

Give some common examples of syntax errors.

A
  • Mistyping a key word
  • Missing out key words (such as END IFs)
  • Opening brackets but not closing them
  • Not having the right number of parameters in brackets
91
Q

What are the main types of error when developing a program?

A
  • Syntax errors

* Logic errors

92
Q

What is the difference in the effects of syntax and logic errors?

A

Syntax errors generally prevent the program from compiling, whereas a logic error may just give an unexpected output.

93
Q

Give some common examples of logic errors.

A
  • Missing brackets from mathematical calculations

* Loops that execute the wrong number of time because a “

94
Q

Describe the structure of a typical testing table.

A
Headings:
• Test purpose
• Test data
• Expected outcome
• Actual outcome
95
Q

When testing a program with number inputs, what inputs should be used?

A
  • Check numbers at both ends of the allowed range of inputs
  • Check numbers just outside allowed range at both ends
  • Check a typical value in the middle of the range
  • Check a non-number input
96
Q

What is valid data?

A

Data that should be allowed by the program.

e.g. If a range of 1 to 10 is allowed, then valid data will be any number between 1 and 10 inclusive.

97
Q

What is invalid data?

A

Data that is not valid and should be rejected by the program.
e.g. If a range of 1 to 10 is allowed, then invalid data will include abc, -251, 0, 11, etc.

98
Q

What is boundary data?

A

Data either side of the range extremes.

e.g. In a range of 1 to 10, boundary data will include 0, 1, 10 and 11.

99
Q

What does IDE stand for?

A

Integrated Development Environment

100
Q

What is an integrated development environment?

A

A software package that helps you write code more easily, allowing writing and testing of code.

101
Q

What are the common tools and facilities available in an integrated development environment?

A
  • Editors
  • Error Diagnostics
  • Run-time Environment
  • Translators
  • Auto-documentation
102
Q

Describe how a common IDE provides an editor and error diagnostics.

A

The IDE may provide:
• Colour-coding of words
• Numbering the lines
• Auto-correcting of constructs

103
Q

Describe how a common IDE provides a run-time environment.

A

The run-time environment provides:
• The screen which you see when running the program
• The feedback you see when running the program (error messages)
• Other debugging tools (e.g. breakpoint)

104
Q

Give an example of an IDE.

A

Visual Basic IDE

105
Q

What is a breakpoint?

A

A tool that allows the program to be stopped at a certain line and the values of variables to be checked.

106
Q

Describe how a common IDE provides a translator.

A

The translator:
• Either compiles or interprets the code
• The compiler will check the syntax, report any errors, and once these have been corrected, will convert the program to machine code

107
Q

Describe how a common IDE provides auto-documentation.

A

The compiler recognises code comments and takes note of all the variables, modules and sub-routines as the project is developed. This is used to generate a text file that can be the basis of the programmer’s technical documentation.