1 / 23

AS Computing

AS Computing. Introduction to Programming. 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. Programming Languages.

levi
Télécharger la présentation

AS Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. First Generation – Machine Code 0010100100100101001001110110101011010100111110110100001010101010110101010101011011011010 • 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: LDA Load Accumulator STA Store Accumulator ADD Adds to Accumulator SUB Subtracts from Accumulator

  9. 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 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: • ASSIGNMENT • SELECTION • ITERATION

  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. Iteration Do while x < 10 x = x + 1 MessageBox x Loop For x = 1 to 10 Messagebox x Next x

  21. 2 Methods of Iteration • Conditional • Unconditional

  22. Conditional Loop • Conditional • Move an object until it reaches a barrier • x=1 • Repeat • Move forward 1 unit • Until x=2 • Infinite Loop

  23. Unconditional Loop • Unconditional • Move an object x number of times • For Counter = 1 to 40 • Move forward 1 unit • Next Counter • Finite Loop

More Related