Presentation is loading. Please wait.

Presentation is loading. Please wait.

2 nd Semester 2004 1 204111 Module1 Introduction to Computer and Programming อภิรักษ์ จันทร์สร้าง Aphirak Jansang

Similar presentations


Presentation on theme: "2 nd Semester 2004 1 204111 Module1 Introduction to Computer and Programming อภิรักษ์ จันทร์สร้าง Aphirak Jansang"— Presentation transcript:

1

2 2 nd Semester 2004 1 204111 Module1 Introduction to Computer and Programming อภิรักษ์ จันทร์สร้าง Aphirak Jansang aphirak.j@ku.ac.th http://www.cpe.ku.ac.th/~aphirak Computer Engineering Department Kasetsart University, Bangkok THAILAND

3 2 nd Semester 2004 2 Outline  Introduction to Computer  How to run program?  Programming Languages  Introduction to Pascal Language

4 2 nd Semester 2004 3 How can we classify computers?  Personal Computer Desktop Computer Notebook PDA – Personal Digital Assistant  Supercomputer  Mainframe High Computation Power

5 2 nd Semester 2004 4 Computer Components  Input Devices  Output Devices  Computing & Processing Unit

6 2 nd Semester 2004 5 CPU Main Memory Input Devices HD Secondary Memory Output Devices Computer Components

7 2 nd Semester 2004 6 Computer Memory  1.Main Memory  2.Secondary Memory

8 2 nd Semester 2004 7 1. Main Memory  Can be devided into 2 Categories RAM (Random Access Memory) ROM (Read Only Memory)  Memory Cell -> Byte -> Bit  1 Byte = 8 bits

9 2 nd Semester 2004 8 2. Secondary Memory  Floppy disk  Hard disk  CDROM  DVDROM Etc… 1 Kbyte = 2 10 = 1024 bytes 1 Mbyte = 2 20 = 1,048,576 bytes 1 Gbyte = 2 30 = 1,073,741,824 bytes

10 2 nd Semester 2004 9 Main Memory VS Secondary Memory  Main Memory Much faster More expensive Volatile  Secondary Memory Slower Less expensive Permanent

11 2 nd Semester 2004 10 Outline  Introduction to Computer  How to run program?  Programming Languages  Introduction to Pascal Language

12 2 nd Semester 2004 11 How to run program?  After boot Process May be Windows XP (Operating System: OS) has been loaded into Main Memory  User tell OS to load program P1  OS Load program P1 from Secondary Memory into Main Memory  OS run program from Main Memory

13 2 nd Semester 2004 12 Outline  Introduction to Computer  How to run program?  Programming Languages  Introduction to Pascal Language

14 2 nd Semester 2004 13 Programming Languages  Machine Language  Assembly Language  High-Level Language

15 2 nd Semester 2004 14 High-level VS Assembly VS Machine Language  High-level Language SUM := A * 2 + ALPHA/3;  Assembly Language MULL3A, #2, R6 DIVL3#3, ALPHA, R7 ADDL3R6, R7, SUM  Machine Language 00011000011 00011001111 10011000111

16 2 nd Semester 2004 15 High-Level Languages  Procedural Language Fortran Cobol Basic C Pascal  Object-Oriented Language C++ Java  Functional Language Lisp  Logic Language Prolog

17 2 nd Semester 2004 16 How to execute program from non-machine language?  1. Interpretation Method  2. Translation Method

18 2 nd Semester 2004 17 1.Interpreation Process Interpreter (on computer) Output Source Program Input

19 2 nd Semester 2004 18 2. Translation Process  Translation Phase  Link Phase  Execute Phase Source Program Translator Object Program Library Linker Execute Program Output CPUInput Data

20 2 nd Semester 2004 19 Translator Example  Pascal Test.pas Pascal compiler Test.exe Source Code Executable Program 1 2 Translation Phase + Link Phase -Ready to use -Not required source code and compiler anymore

21 2 nd Semester 2004 20 Translators  Assembler (assembly)  Compiler (High-level language)

22 2 nd Semester 2004 21 Outline  Introduction to Computer  How to run program?  Programming Languages  Introduction to Pascal Language

23 2 nd Semester 2004 22 Introduction to Pascal  Procedural programming language  Developed by Prof.Niklaus Wirth (Switzerland, 1970s)  Named in honor to mathematician, Blaise Pascal  Most popular -> Turbo Pascal

24 2 nd Semester 2004 23 Pascal Program Structure  Program Heading  Declarations  Main Routine (Program body)

25 2 nd Semester 2004 24 Pascal Program Structure program myFirstProgram; const myStudentId = 1234567; var courseTaken: integer; begin write(‘Please Enter a number of courses’); read(‘courseTaken’); writeln(‘Student’, myStudentId, ‘ takes ’, courseTaken, ‘ courses in this semester’); end. Program Heading Declarations Program Body

26 2 nd Semester 2004 25 Basic Elements of Pascal  Character set  Reserved words  Identifiers  Constants / Variables  Statement / Expression  Function / Procedure

27 2 nd Semester 2004 26 Character set  Three categories Letter (A…Z, a…z) Digit (0…9) Special character (+ - * / _ = ! <> []{})

28 2 nd Semester 2004 27 Reserved Words( คำสงวน )  Predefined meaning and usage  Cannot be redefined by the programmer  Examples program begin / end const / var etc.

29 2 nd Semester 2004 28 Reserved Words program myFirstProgram; const myStudentId = 1234567; var courseTaken: integer; begin write(‘Please Enter a number of courses’); read(‘courseTaken’); writeln(‘Student’, myStudentId, ‘ takes ’, courseTaken, ‘ courses in this semester’); end.

30 2 nd Semester 2004 29 Identifiers( ตัวบ่งชี้ )  Symbolic names for program elements  Rules for constructing identifiers Letters, digits, and under score (_) First character  letter Can be long (63 char) Reserved words are not allowed

31 2 nd Semester 2004 30 Identifiers( ตัวบ่งชี้ ) program myFirstProgram; const myStudentId = 1234567; var courseTaken: integer; begin write(’Please Enter a number of courses’); read(courseTaken); writeln(’Student’, myStudentId, ’ takes ’, courseTaken, ’ courses in this semester’); end.

32 2 nd Semester 2004 31 Identifier( ตัวบ่งชี้ ) examples  Valid examples score, count, total score1, count99, total09 score_1, count_99, total_99 myStudentId my_student_id  Invalid examples point&score total-number 9points

33 2 nd Semester 2004 32 Notes for Identifiers( ตัวบ่งชี้ )  Identifiers are case-insensitive mystudentId Mystudentid MYSTUDENTID  Some identifiers are predefined meanings (Standard Identifiers – can be redefined) interger, real write, writeln, read, readln

34 2 nd Semester 2004 33 Identifiers( ตัวบ่งชี้ ) program myFirstProgram; const myStudentId = 1234567; var courseTaken: integer; begin write(’Please Enter a number of courses’); read(courseTaken); writeln(’Student’, myStudentId, ’ takes ’, courseTaken, ’ courses in this semester’); end.

35 2 nd Semester 2004 34 Conclusions  In this class we have learned Computer Categories/Components Programming Language  Machine/Assembly/High-level Language Intro to Pascal Language  Pascal Structure program heading declarations program body Reserved Words, Identifiers  Basic Pascal – Reserved Words, Identifiers

36 2 nd Semester 2004 35 Programming Strategy  Don’t rush to key in the computer  Think carefully about the problem  Try to solve by hand  Plan your program  Test by hand if possible  Start programming  Program Compilation  Testing / Debug  Documentation  Maintenance

37 2 nd Semester 2004 36 What will we learn in Next Class? Pascal Language Basic


Download ppt "2 nd Semester 2004 1 204111 Module1 Introduction to Computer and Programming อภิรักษ์ จันทร์สร้าง Aphirak Jansang"

Similar presentations


Ads by Google