5 0 PROGRAMMING Duration 10 weeks Prepared by
5. 0 PROGRAMMING Duration: 10 weeks Prepared by Ong Lay Peng Copyright © 2007
Activity 1: Turtle Graphics • • Hold the pencil upright. Place the pencil tip on a paper. Keep the pencil tip on the paper at all times during the drawing process. Perform a task based on the following instructions. move forward 3 cm. rotate 135 o to the right. move forward 3. 5 cm. rotate 135 o to the left. move forward 3 cm. **Note: Turtle graphics in one of the feature in a programming language called LOGO. WHAT IS IN YOUR DRAWING ? ? ?
5. 1 Basic Programming Concepts Learning outcomes: – Define Program and Programming Language • State the definition of programming language. – Identify the levels and generations Of Programming Languages • Identify the generations of low-level programming languages with examples. • Identify the generations of high-level programming languages with examples. Duration: 2 periods
Definition of Program Task A series of instructions
Definition of Program A series of instructions that directs a computer to perform task. Private Sub cmd. Calculate_Click() Dim area As Double area = Val(Text 1. Text) * Val(Text 2. Text) lblarea. Caption = Format. Number(area, 2) End Sub Private Sub cmd. Clear_Click() Text 1. Text = "" Text 2. Text = "" lblarea. Caption = "" Text 1. Set. Focus End Sub Private Sub cmd. Exit_Click() End Sub Figure B Figure A
Definition of Program A person who writes and modifies a computer program is called _______ , sometimes called developer. A developer uses a _____________ to write a computer program.
Definition of Programming Language A set of words, symbols, and codes that enables a programmer to communicate instructions to a computer. Several hundreds of programming languages exist today. Visual Basic Java C C++ COBOL J++ C# BASIC PASCAL Prolog SQL Logo
Definition of Programming Language Each instruction causes computer to carry out one step of the task
Definition of Programming Language • Each programming language has its own rules for writing the instructions. Java Programming Language public class Hello. World { public static void main (String[] args) { System. out. println("Hello, world!n"); } } Visual Basic 6 Programming Language Private Sub cmd_Click() Text 1. Text=“Hello, World!” End Sub You cannot apply the rules of Visual Basic Programming Language in C or Java.
Definition of Programming Language used to instruct a computer to perform a specific task called _____.
Definition of Programming Languages often are designed for specific purposes, such as scientific applications, business solutions or web page development Logo: A programming language designed rea lly for young kids. Prolog: A language used for the developm ent of artificial intelligence applications. COBOL: A language designed for business ap plication.
Definition of Programming Language Answer all the questions What is computer program ? Give two examples of computer programs. What is programming Language ? Explain the function of programming language.
Levels and Generations Of Programming Languages 2 levels of programming languages • • Low-level language High-level language Low-level language – A language that is machine-dependent. – A machine-dependent language runs on only one particular type of machine. These programs are not easily portable to other types of computers. – Each language instruction in low-level language usually equates to a single machine instruction.
Levels and Generations Of Programming Languages High-level language – A language that is machine-independent. – A machine-independent language runs on different types of machines and operating system. – Each language instruction in high-level language usually equates to multiple machine instructions.
Levels and Generations Of Programming Languages • Based on the text in slide 11 & 12, complete the table below. The differences between low-level language and high-level language Low-level language High-level language
Examples Of Programming Languages
Levels and Generations Of Programming Languages Low-level languages • 2 types: – Machine Language – Assembly Language High-level languages • 3 types: – Third-generation language (3 GL) – Fourth-generation language (4 GL) – Fifth-generation language (5 GL)
Levels and Generations Of Programming Languages Machine Language – First generation programming language – The only language the computer directly recognizes. Therefore, a machine language program does not require a translator.
Levels and Generations Of Programming Languages Machine Language – The instructions in machine language use a series of binary digits (1 s and 0 s) or a combination of numbers and letters that represents binary digits. – Readily understood by computers; less intelligible by humans – Coding in machine language is tedious and time-consuming.
Levels and Generations Of Programming Languages Assembly Language – 2 nd generation programming language The instructions use : Symbolic address (meaningful name) to identify the storage location symbolic instruction codes (meaningful abbreviations). Example: Use the name RATE to refer to the storage location that contains a pay rate. A for addition, C for Compare, L for Load and M for multiply.
Levels and Generations Of Programming Languages Assembly Language
Low-level Programming Languages Assembly Language – The assembly language is not the native language of computer. Thus, the program must be converted into machine language using a translator called assembler, before a computer can execute/run it. – Easier to code as compared to machine language. But it can still be difficult to learn. “The computer cannot directly run the assembly source program. ”
High-level Programming Languages Third-Generation Language – Procedural language – The instructions in 3 GL use a series of English-like words. – Many 3 GLs also use arithmetic operators such as * for multiplication and + for addition. Programmers writes the instructions that tell the computer what to accomplish and how to do it. The program is based on a logical step-by-step process for solving a problem.
High-level Programming Languages Third-Generation Language – The 3 GL is not the native language of computer. Thus, the program must be converted into machine language using a translator either compiler or interpreter, before a computer can execute/run it. 3 GL Compiler / Interpreter Machine language – Simplify the program development process for programmers. Easier to code and maintain a program as compared to low-level language. – Examples: COBOL, Pascal, C, Fortran, BASIC, C++, Java, ALGOL, Delphi
High-level Programming Languages Fourth-Generation Language – Non-procedural language – Allow people to develop program with fewer commands Non-procedural programming languages allow users and programmers to specify the results they want without specifying how to solve the problem.
High-level Programming Languages Fourth-Generation Language – The instructions in 4 GL use English-like words or graphical environment to retrieve data from files or database. – Examples SQL , Progress 4 GL, Cold. Fusion (web development), GEMBase, Build. Professional, FOCUS, Informix-4 GL.
High-level Programming Languages 3 GL Vs 4 GL Example: In d. BASE, the command List displays all the records in a data file. In secondand third-generation languages, instructions would have to be written to read each record, test for end of file, place each item of data on screen and go back and repeat the operation until there are no more records to process. d. BASE 3 GL d. BASE 4 GL use customer do while. not. eof() list name, address ? name, address skip enddo use customer list name, address
High-level Programming Languages Fifth-Generation Language – 5 GLs are designed to make the computer solve the problem for you. – The programmer only needs to worry about what problems need to be solved and what conditions need to be met, without worrying about how to implement a routine or algorithm to solve them. – mainly used in artificial intelligence research. – Examples: Prolog, Mercury, OPS 5
Assessment • Draw a hierarchy chart to classify the generations of each level of programming language. Programming Language Example Self - assessment Example
Summary Programming Languages Generation Low-level programming languages: • More technical • not portable • less user-friendly • Run faster • Lengthy 1 GL Machine Language High-level programming languages: • Less technical • Portable • More user-friendly • Run slower • shorter than 1 GL and 2 GL 3 GLs Procedural language 2 GL Assembly Language 4 GLs Non-procedural language 5 GLs mainly used in artificial intelligence research
- Slides: 30