Escolar Documentos
Profissional Documentos
Cultura Documentos
Input
Output
assignment
Variable
Local variable
Global variable
Constants
Sub-routines
Worked example
Identify one assignment and one global variable in this code
Global variable
Declaration
Beginning subroutine
Declarations
End of sub-routine
Answer:
Percentage = (score/totalmarks)/100
MessageBox.Show (percentage + %)
End Sub
Assignment
Constant
a)Dec
b)Assignment
Age=currentyear yearofbirth
MessageBox.Show (age)
d)Output
End Sub
Explain why software developers annotate their code
Software developers annotate their code when writing programs to allow for maintenance. Annotations
are comments written into the code to explain what parts of the program are there for.
Annotating code is useful for a programmer who has been asked to edit or maintain code, as the original
developers comments will help them to understand how it works. Original authors can use their own
annotations as reminders if they need to maintain the code.
Data Types
Complete the following table:
Variable Data Type
Character
String
Definition
A single letter or
number
Any combination of letters,
numbers, symbols and
spaces
Example
M
L McGinn
A whole number
A number with fractions
Integer
Real
Boolean
True or false
23
23.34
True
Worked example
Suggest an appropriate data type for each variable
CustomerName
String
Gender
Character
Age
Integer
Data structures
How is the first element of an array identified?
A
B
C
D
0
1
2
3
1
Giraffe
2
Penguin
3
Elephant
4
Tiger
5
Monkey
Worked example:
Lynda is creating a program for a game of chess.
What data structure should she use? Justify your choice
2D array
It represents the two axes on the board. Each dimension can store
an axis of the board.
6
Peacock