html5-img
1 / 36

INC 161 , CPE 100 Computer Programming

INC 161 , CPE 100 Computer Programming. Lecturer Associate Prof. Dr. Poj Tangamchit. About the Instructor. Office: CB40603 (CB4 6 th floor) Control System and Instrumentation Eng. (INC) Tel: x-9094 E-mail: poj.tan@kmutt.ac.th Research Interest: Robotics, Artificial Intelligence (AI).

hbernier
Télécharger la présentation

INC 161 , CPE 100 Computer Programming

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. INC 161 , CPE 100Computer Programming Lecturer Associate Prof. Dr. Poj Tangamchit

  2. About the Instructor Office: CB40603 (CB4 6th floor) Control System and Instrumentation Eng. (INC) Tel: x-9094 E-mail: poj.tan@kmutt.ac.th Research Interest: Robotics, Artificial Intelligence (AI)

  3. Course Details • 3 Credits 2 credits Lecture + 1 credits Practice • Class time 4 hours / week • 2 hours lecture + 2 hours lab • Review + Homework 6-12 hours/week • Teaching Style = Self Lecture + Practice

  4. Scoring & Grading Midterm Exam 40% Final Exam 40% Homework 15% In-class attendance 5 % Grading follows the faculty of Engineering’s standard procedure.

  5. Homework & Assignment Homework takes time. Allocate 6-12 hours each week for it. Students need self-practice outside class time.

  6. Copy of Homework (Plagiarism) Students should do their homework separately. If two or more students have similar homework, they will get homework score = -100%, no matter who is the original. Program codes will bechecked byINC-MOSS (Measure Of Software Similarity developed by INC) This is our standard used for judge copying.

  7. Textbooks Schaum's Outline of Programming with C, 2nd Edition By Byron S. Gottfried ISBN-139780070240353

  8. Class Webpage http://www.inc.eng.kmutt.ac.th/inc161 • Announcement • Lecture Slides Facebook discussion group https://www.facebook.com/groups/138077300115052/

  9. What is a computer? Computer = Data Processing Machine

  10. Why computers are important? • Document Processing • High-Tech Machine Control • Mobile Embedded Devices

  11. Computer Specification

  12. HDD, Ram, Cache are data storage CPU is data processing unit Hard disk Ram Cache CPU

  13. What is inside RAM?

  14. Real Worldrepresentation of data ‘0’ is represented by voltage 0 volts ‘1’ is represented by voltage 5 volts (TTL level)

  15. How much data? 1 bit = 1 unit of data (can be represent as ‘0’ or ‘1’) 1 byte = 8 bit 1 kilobyte = 1024 bytes 1 megabyte = 1024 kilobytes

  16. ‘0’ and ‘1’ can represent everything • Number - 33, 55, 1.2332 • Word, Sentence - .txt .doc • Picture - .jpg .bmp • Video - .mpg .avi • Sound - .wav .mp3

  17. Functionality of the CPU Command 001101110101 Input 0011010101 0101010000 1001010101 0101010001 0101010110 0010101000 Output CPU 001101110101 010101011000

  18. The purpose of this course Know how to give commands to the CPU to make it work as we want. Command 001101110101 Input 0011010101 0101010000 1001010101 0101010001 0101010110 0010101000 Output CPU 001101110101 010101011000

  19. Machine Language(Code)for 32-bit OS 32 digits Add - 01010010010100100101001001010010 Subtract- 11010110110100100101001001010111 Multiply- 00010110100100100100001001010000 Division- 10010010110100100101001000010001 : :

  20. Hard to remember? Suppose we want to command the CPU Add Add Subtract Multiply What is the code?

  21. Compiler Compiler translates a language to machine code. 010101000010010101010010001010101010010101010100001010010010100 Add Add Subtract Compiler

  22. Computer Programming Languages Three types of programming languages • Machine code or machine languages A sequence of 0’s and 1’s giving machine specific instructions Example: 00011001 2. Assembly language Using meaningful symbols to represent machine code. Example: add hl,de Assembler: Assembly code  machine code Disassembler: machine code  assembly code

  23. Computer Programming Languages 3. High-level languages Similar to everyday English and use mathematical notations (processed by compilers or interpreters) Example of a C statement: a = a + 8;

  24. Computer Programming Languages 3. High-level languages Similar to everyday English and use mathematical notations (processed by compilers or interpreters) Example of a C statement: a = a + 8;

  25. Comparison of High-Level Language with Machine Code and Assembly Code The memory addresses, machine code, and assembly code corresponding to a C statement a = a + 8 for the Rabbit 3000 8-bit microprocessor. Memory address Machine code Assembly code ------------------------------------------------------------------------------------- 0X1EA1 000100010000100000000000 ld de,0x0008 0X1EA4 1100010000000000 ld hl,(sp+0) 0X1EA6 00011001 add hl,de 0X1EA7 1101010000000000 ld (sp+0),hl

  26. Topics • Expression • Operation • Flow Control • if for while • Function • Data type: int float char • Array • Pointer • Structure Command 001101110101 Input 0011010101 0101010000 1001010101 0101010001 0101010110 0010101000 Output CPU 001101110101 010101011000

  27. How can we give commands to a computer? By running the program .exe = executable program .txt = text file .jpg = pictures .avi = audio+video file

  28. C Programming Language

  29. Command Compiler translates a language to machine code. 010101000010010101010010001010101010010101010100001010010010100 Add Add Subtract Compiler Learn this format

  30. C Program Structure main () { } Put commands in here

  31. Variable Declaration We can define a part of memory to store data. We can give a name to it. Later, we can refer to it by this name. However, a name must not be reserved words.

  32. int = integer float = floating point char = character Follow with variable name e.g. int a; (Every command in C must end with semi-colon)

  33. Sample Program main () { int i; float val; char ww; }

  34. Inside Memory ww val 001111111 00110000 00000000 i Cache, Ram, HDD

  35. Reserved Words

  36. Comments Comments of a C program can be enclosed within a pair of delimiters /* and */. The symbol // will comment out a subsequent text terminated at the end of a line. /* This is a comment */ /* This is a comment across multiple lines */ printf(”Hello, world\n”);// This is a comment (terminated at the end of line)

More Related