Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 2 Technology Systems

Similar presentations


Presentation on theme: "Unit 2 Technology Systems"— Presentation transcript:

1 Unit 2 Technology Systems
BTEC First Diploma in Information and Creative Technology

2 Learning aims Understand how the components of technology systems work together. Understand how data flows between internal components of a computer and is processed to provide information. Understand different types of software. Lesson Aim: Understand how to write a computer program

3 Writing computer programs
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 help with maintaining the software

4 Programming terms ACTIVITY: Explain the following programming terms
Variable Declaration Scope Subroutine Assignment Constant

5 Programming terms Key term Variable
Memory that the programmer declares with a name which the program can use for calculations or outputs Declaration A statement that gives the name of the variable and states what type of data it can contain Scope How much of the program can use the variable Subroutine A set of instructions designed to perform an operation within a program Assignment A statement that assigns a value to a variable Constant Very similar to a variable, except that the constant is given a value in the declaration statement and that value is not changed by other parts of the program

6 Variables Variables are used to hold data when the program runs – a variable is like a box with a name on it, you can put data into the 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.

7 Declaration statement
Dim QuizScore As Integer In this statement, a variable named QuizScore is declared to be used to hold whole numbers (integers). The position of the declaration statement in the program defines the scope of the variable. The scope can be local or global: A local variable has the declaration inside the subroutine where it can be used. The variable is then local to that subroutine and cannot be used elsewhere in the program. A global variable has the declaration outside of all the subroutines at the start of the program. The variable can then be used anywhere in the program.

8 Assignment statement Some programming languages need global variable declaration statements to be in a module alongside other parts of the program, such as forms. An assignment statement in a program is where a value put inside it or where the value already held there is 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).

9 Constant 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, e.g. Pi () or gravity.

10 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.

11 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 evert time an event handler is added to a control. The event handler for an object is the code that runs when that event occurred. A button will have an event handler for the click event, with code that runs when the user clicks on the button.

12 Annotations Software developers always 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 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.

13 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 allowed to be input. A variable can be declared to have a data type, including: Character; String; integer; Real; Boolean

14 Activity Investigate the following data types, create a table which explains what they are and provides an example. Variable data type Explanation Typical data held in the variable Character Allows any single letter or number R 3 String Integer Real Boolean

15 Variable data types Variable data type Explanation
Typical data held in the variable Character Allows any single letter or number R 3 String Allows any combination of letters, numbers and spaces RJ Macey Integer For whole numbers 356 Real For numbers with both whole parts and fractional parts 3.24 Boolean Can only hold true or false TRUE

16 Data Structures Programs allow the use of data structures with variables, including records and simple arrays. A record data structure contains fields to store information in a similar way to a database table. An array data structure is a variable with many parts, 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 E.g. an array named 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 to 99

17 Activity Go to www.Code.org
Select a game and click on Java Script and Try Now!


Download ppt "Unit 2 Technology Systems"

Similar presentations


Ads by Google