Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Information and Creative

Technology Unit 2 Technology Systems


Writing Computer Programs

Level 2 BTEC Information and Creative Technology


Introduction
Computer programming constructs and techniques are the basic
building blocks of a computer program. They are used by
professional software developers to produce effective and accurate
software and also helps with maintaining the software.

This PowerPoint introduces the basic constructs and techniques


used in computer programming. This knowledge and understanding
will help you to discover the fun of writing your own simple
programs.

Level 2 BTEC Information and Creative Technology


Variables
Variables are used to hold data when the programs runs. You can
think of a variable as rather like a box with a name on it. You can put
data on into a box, move it to another box or change it.
Before a variable is used it should be declared so the program knows
the name of the variable, the type of data expected to be kept there
and how much of the program can use the variable.

Level 2 BTEC Information and Creative Technology


Assignment
Assignment is setting a variable to a value. An assignment statement in a
program is where a variable has a value put inside it or where the value
already held there has changed. The following assignment statement will put a
value of 20 inside a variable named VAT:
VAT=20
When a value is assigned to a variable, it will be kept there and can be used by
the program. A variable can hold a value that can change (vary).
A constant is like a variable in that it can be referenced by a program many
times, but the value of a constant is specified only once. A constant is often
used to represent a value which will not change in that program, for example
Pi (π) or gravity.

Level 2 BTEC Information and Creative Technology


Input and Output
A program needs input to get information or control from the user.
The program then uses this impact to produce the required results.
Input could be a number typed into a text box that is then used by a
calculation to work out a result. There are lots of other possible
inputs, including form combo boxes, buttons and many other form
objects.

Level 2 BTEC Information and Creative Technology


Subroutines
Programs usually have subroutines to structure the code into small
sections. Each subroutine is there for a particular part of the
program.
Modern programs naturally structure themselves into subroutines,
as a new one is created every time an event handler is added to a
control.

Level 2 BTEC Information and Creative Technology


Annotations
Professional software developers always annotate their code when
writing programs to allow for maintenance. Annotations are
comments written into the code to explain what parts are there for.
Annotating code is useful for a programmer who has been asked to
edit or maintain code, as the original developer’s comments will
help them understand how it works. Original authors can also use
their own annotations as reminders if they need to maintain the
code.

Level 2 BTEC Information and Creative Technology


Data Types
Programs need to use data for calculations, comparisons and for output to
various devices. The best programs will always use the most appropriate data
types to make the most effective use of memory and to ensure that only the
correct types of data are being allowed to be input. A variable can be
declared to have a data type, including:

• Character – allows any single letter or number.


• String – allows any combination of letters, numbers and spaces.
• Integer – for whole numbers.
• Real – for numbers with both whole parts and fractional parts.
• Boolean – can only hold true or false.
Level 2 BTEC Information and Creative Technology
Examples of Data
Types

Level 2 BTEC Information and Creative Technology


Common Programming Terms

Level 2 BTEC Information and Creative Technology


Data Structures
A data structure is an organisation that data fits into. Different
structures are used for particular purposes and choosing the correct
data structure is an important part of designing a program.
Programs allow the use of data structures with variables, including
records and simple arrays.

Level 2 BTEC Information and Creative Technology


Records
A record data structure contains fields to store information in a
similar way to a database table.
Records are like a database. They use tables and fields.
A database is a collection of data.
Data about one topic is stored in a table, e.g. information about all
of the students in a college.
A row in a table that stores data about a single item is a record, e.g.
information about one student.
The columns in a table store categories that are called fields, Name,
Level 2 BTEC Information and Creative Technology
Address, Gender, and date of birth.
Arrays
An array data structure is a variable with many parts, in simple
terms they can be thought of as tables with a number of rows and
columns.
The array has a number inside brackets (called a subscript), which is
used to identify an item in the array that is required. For example,
an array called customer (100) that has just one column and 100
rows, so customer (12) would be the contents of item number 12 in
the list 0 – 99.

Level 2 BTEC Information and Creative Technology


Arrays
An array is a type of variable that can hold several values (unlike a
normal variable, which can only hold one a t a time, e.g. score = 3).
In simple terms they can be thought of as tables with a number of
rows and columns.
Each piece of data in an array is referred to by a number, which
starts at 0 and marks the position of the data.

Level 2 BTEC Information and Creative Technology


Arrays
The dimensions of the array are the different groups of data stored, e.g. ID array has one
group of data, 2D has two related groups.

Level 2 BTEC Information and Creative Technology


Questions to check knowledge
Complete the Google form
https://goo.gl/forms/5dVwPVLc3jl35HnP2
Questions to check knowledge
1) What is the difference between a global variable and a local
variable?

2) What data can be held in a variable that is declared to be a


‘String’?

3) Why do programmers annotate their code?


Activity
https://code.org/starwars

https://codecombat.com/play/game-dev-hoc?hour_of_code=true

You might also like