Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,"— Presentation transcript:

1 AS Computing Introduction to Programming

2 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

3 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 a foreign language  Rules are more rigid than a foreign language

4 Generations of Programming Languages Computers have been around since 1940s Early computers programmed by changing switch settings to represent binary data Bletchley Park

5 Alan Turing

6 Difference Engine – Charles Babbage

7 0010100100100101001001 1101101010110101001111 1011010000101010101011 0101010101011011011010 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

8 Second Generation – Assembly Language Use words rather than 0s and 1s Simple translation of 1 word to 1 machine code instruction Uses mnemonics: LDALoad Accumulator STAStore Accumulator ADDAdds to Accumulator SUBSubtracts from Accumulator

9 Low Level Languages ;// ADDRESSOPCODEASM ; ---------------------------------- $0000$2A82GOTOhifi_main $0004$delays_delay_1us: $0004$0000nop $0005$0000nop $0006$0008RETURN $0007$delays_delay_5500us: $0007$300FMOVLW15 $0008$1303BCFSTATUS,RP1 $0009$1283BCFSTATUS,RP0 $000A$00F0MOVWFSTACK_0 $000B$30FFMOVLW255 $000C$00F1MOVWFSTACK_1 $000D$delays_L_8: $000D$0BF0DECFSZSTACK_0, F $000E$2810GOTOdelays_L_9 $000F$2813GOTOdelays_L_10 $0010$delays_L_9: $0010$0BF1DECFSZSTACK_1,F $0011$2810GOTOdelays_L_9 $0012$280DGOTOdelays_L_8 $0013$delays_L_10: $0013$303EMOVLW62 $0014$00F0MOVWFSTACK_0 $0015$delays_L_11: $0015$0BF0DECFSZSTACK_0, F Machine Code & Assembly language are: Processor Dependant Collectively known as Low Level Languages

10 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

11 Many Different High Level Languages Written to cope with the demands of specific types of problem: Business Applications Databases Web Pages

12 High Level Language Classifications Procedural or Imperative Use a sequence of instructions, executed in a particular order Object Oriented Use objects and inheritance Declarative Prolog, SQL Facts and rules based

13 Translating High Level Languages 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

14 Programming Constructs Most high level languages construct their statements in a similar way:SEQUENCEASSIGNMENTSELECTIONITERATION

15 Assignment Age = 34 Sets the variable Age to the value of 34 Assignment is fundamental to programming

16 Types of Variables Integer Long Integer Real Number Number with decimal point String Alphanumeric Boolean Yes/No or True/False

17 Data Types Current Rate of VAT Real Todays Date String / Date? Total takings at a shop Real If a school has a sixth form or not Booleans Number of Pupils in a School Integer

18 Selection - If Compares values and decides outcome If Age < 17 Then Showmessage(‘Under Age to drive’); Else Showmessage(‘Old enough to drive’); End If

19 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

20 2 Methods of Iteration Count Controlled Condition Controlled

21 Iteration Do while x < 10 x = x + 1 MessageBox x Loop For x = 1 to 10 Messagebox x Next x Count Controlled Condition Controlled


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

Similar presentations


Ads by Google