+ All Categories
Home > Documents > AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a...

AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a...

Date post: 12-Jan-2016
Category:
Upload: brook-kelly
View: 218 times
Download: 0 times
Share this document with a friend
21
AS Computing AS Computing Introduction to Introduction to Programming Programming
Transcript
Page 1: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

AS ComputingAS Computing

Introduction to Introduction to ProgrammingProgramming

Page 2: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

What is a Computer Program?

A list of instructions that a computer must work through, in a logical sequence, to carry out a specific task

Computer programs are written in a programming language

Page 3: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Programming Languages

Many different languages and many different versions of same language

Each language has a vocabulary and rules that define arrangement - SYNTAX

Fewer words to

learn than aforeign language

Rules are more

rigid than a foreign language

Page 4: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Generations of Programming LanguagesComputers have been around since 1940s

Early computers programmed by changing switch settings to represent binary data

Bletchley Park

Page 5: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Alan Turing

Page 6: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Difference Engine – Charles Babbage

Page 7: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

0010100100100101001001110110101011010100111110110100001010101010110101010101011011011010

First Generation – Machine Code

Processors can only work with Binary Digits

All instructions given to a computer must be in a pattern of zeros and ones

Page 8: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Second Generation – Assembly Language

Use words rather than 0s and 1s

Simple translation of 1 word to 1 machine code instruction

Uses mnemonics:LDA Load AccumulatorSTA Store AccumulatorADD Adds to AccumulatorSUB Subtracts from Accumulator

Page 9: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Low Level Languages;// ADDRESS OPCODE ASM; ----------------------------------$0000 $2A82 GOTO hifi_main$0004 $ delays_delay_1us:$0004 $0000 nop$0005 $0000 nop$0006 $0008 RETURN$0007 $ delays_delay_5500us:$0007 $300F MOVLW 15$0008 $1303 BCF STATUS,RP1$0009 $1283 BCF STATUS,RP0$000A $00F0 MOVWF STACK_0$000B $30FF MOVLW 255$000C $00F1 MOVWF STACK_1$000D $ delays_L_8:$000D $0BF0 DECFSZ STACK_0, F$000E $2810 GOTO delays_L_9$000F $2813 GOTO delays_L_10$0010 $ delays_L_9:$0010 $0BF1 DECFSZ STACK_1,F$0011 $2810 GOTO delays_L_9$0012 $280D GOTO delays_L_8$0013 $ delays_L_10:$0013 $303E MOVLW 62$0014 $00F0 MOVWF STACK_0$0015 $ delays_L_11:$0015 $0BF0 DECFSZ STACK_0, F

Machine Code & Assembly language are:

Processor Processor DependantDependant

Collectively known as Low Level Languages

Page 10: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Third Generation - High Level Languages

Problem oriented languages, easy to understand

if Age >=17 Then Showmessage(‘Can drive a car’)

Based on what the program must do, rather than what the processor and memory do

PORTABLE – programs can be used on different types of computer BASIC JAVA PASCAL C

Page 11: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Many Different High Level Languages

Written to cope with the demands of specific types of problem:

Business Applications

Databases

Web Pages

Page 12: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

High Level Language Classifications

Procedural or ImperativeUse a sequence of instructions, executed in a particular order

Object OrientedUse objects and inheritance

DeclarativeProlog, SQLFacts and rules based

Page 13: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Translating High Level Translating High Level LanguagesLanguages

Easy for people to use, but computers can not understand them

The translation from high level code to machine code is a more complex process than for assembly language

There are 2 types of Translator:

INTERPRETER

COMPILER

Page 14: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Programming Constructs

Most high level languages construct their statements in a similar way:

SEQUENCESEQUENCE

ASSIGNMENTASSIGNMENT

SELECTIONSELECTION

ITERATIONITERATION

Page 15: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Assignment

Age = 34Age = 34

Sets the variable Age to the value of 34

Assignment is fundamental to programming

Page 16: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Types of Variables

IntegerLong IntegerReal Number

Number with decimal point

StringAlphanumeric

BooleanYes/No or True/False

Page 17: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Data TypesCurrent Rate of VAT

Real

Todays DateString / Date?

Total takings at a shopReal

If a school has a sixth form or notBooleans

Number of Pupils in a SchoolInteger

Page 18: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Selection - If

Compares values and decides outcome

If Age < 17 Then

Showmessage(‘Under Age to drive’);

Else

Showmessage(‘Old enough to drive’);

End If

Page 19: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Iteration

Often useful to repeat a section of code

Counting the number of letters in a word

Keeping an object moving, until it reaches a barrier

Doing something until a condition is met

Doing something a certain number of times

Doing something while a condition is true

Page 20: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

2 Methods of Iteration

Count Controlled Count Controlled

Condition ControlledCondition Controlled

Page 21: AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,

Iteration

Do while x < 10

x = x + 1

MessageBox x

Loop

For x = 1 to 10

Messagebox x

Next x

Count ControlledCount ControlledCount ControlledCount Controlled

Condition ControlledCondition ControlledCondition ControlledCondition Controlled


Recommended