Presentation is loading. Please wait.

Presentation is loading. Please wait.

INC 161 , CPE 100 Computer Programming

Similar presentations


Presentation on theme: "INC 161 , CPE 100 Computer Programming"— Presentation transcript:

1 INC 161 , CPE 100 Computer 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 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 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 be checked by INC-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

8 Class Webpage http://www.inc.eng.kmutt.ac.th/inc161 Announcement
Lecture Slides Facebook discussion group

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 World representation 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, Word, Sentence - .txt .doc Picture - .jpg .bmp Video - .mpg .avi Sound - .wav .mp3

17 Functionality of the CPU
Command Input Output CPU

18 The purpose of this course
Know how to give commands to the CPU to make it work as we want. CPU Input Output Command

19 Machine Language(Code) for 32-bit OS
32 digits Add Subtract Multiply Division :

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.
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: 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 bit microprocessor. Memory address Machine code Assembly code 0X1EA ld de,0x0008 0X1EA ld hl,(sp+0) 0X1EA add hl,de 0X1EA ld (sp+0),hl

26 Topics CPU Expression Operation Data type: int float char Flow Control
if for while Function Data type: int float char Array Pointer Structure CPU Input Output Command

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.
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 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)


Download ppt "INC 161 , CPE 100 Computer Programming"

Similar presentations


Ads by Google