Transcript pps
Lecture 1
Introduction To Computers
by
Jumail Bin Taliba
Faculty of Computer Science & Information System
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 1
Today’s Topics
•Computer Systems •Computing Environments •Computer Languages •System Development
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 2
Figure 1-1: A computer system Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 3
Figure 1-2: Basic hardware components Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 4
Computer Hardwares
– Five main components
• Input devices – Allows communication to the computer • Output devices – Allows communication to the user • Processor (CPU) • Main memory (primary storage) – Memory locations containing the running program • Secondary memory (auxiliary storage) – Permanent record of data often on a disk
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 5
Computer Memory
• Main Memory
– Long list of memory locations • Each contains zeros and ones • Can change during program execution – Binary Digit or Bit • A digit that can only be zero or one – Byte • Each memory location has eight bits – Address • Number that identifies a memory location
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 6
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 7
Larger Data Items
• Some data is too large for a single byte
– Most integers and real numbers are too large – Address refers to the first byte – Next few consecutive bytes can store the additional bits for larger data
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 8
Data or Code?
• ‘A’ may look like 01000001 • 65 may look like 01000001 • An instruction may look like 01000001 • How does the computer know the meaning of 01000001?
– Interpretation depends on the current instruction
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 9
Secondary Memory
• Main memory stores instructions and data while a program is running.
• Secondary memory
– Stores instructions and data permanently – A file stores data or instructions in secondary memory
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 10
Secondary Memory Media
• A computer might have any of these types of secondary memory – Hard disk • Fast • Fixed in the computer and not normally removed – Floppy disk • Slow • Easily shared with other computers – Compact disk • Slower than hard disks • Easily shared with other computers • Can be read only or re-writable
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 11
The Processor
• Typically called the CPU
– Central Processing Unit – Follows program instructions – Typical capabilities of CPU include: add subtract multiply divide move data from location to location
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 12
Figure 1-3: Types of software Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 13
Figure 1-4: Software Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 14
Figure 1-5: Personal computing environment Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 15
Figure 1-6: Time-sharing Environment Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 16
Figure 1-7: Client-server environment Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 17
Figure 1-8: Types of computer languages Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 18
Example:
Machine Language:
the only language understood by a computer
0101 1000 0001 0000 0101 1011 0001 0000 0101 0000 0001 0000
Assembly/Symbolic language
MOVE #$1,D1 MOVE #$8,D0 ADD D0,D1
High-level language
LUAS = PANJANG * LEBAR IF LUAS > 50 GOTO BESAR ELSE GOTO KECIL
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 19
Figure 1-9: Building a C program Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 20
Figure 1-10: Executing programs Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 21
Figure 1-11: Process of system development Building programs
•Edit •Compile •Link •Run
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 22
Figure 1-11: Process of system development Understand the problem:
•Input •Output •Process
Develop the solution
( Algorithm
•Structure chart •Pseudocode •Flowchart
):
Converting design to computer codes.
e.g: Flowchart -> C program Algorithm is the steps to solve problems
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 23
Testing and Debugging
• Bug – A mistake in a program • Debugging – Eliminating mistakes in programs – Term used when a moth caused a failed relay on the Harvard Mark 1 computer. Grace Hopper and other programmers taped the moth in logbook stating: “First actual case of a bug being found.”
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 24
Program Errors
• Syntax error – Violation of the grammar rules of the language – Discovered by the compiler • Error messages may not always show correct location of errors • Run-time error – Error detected by the computer at run-time • Logic error – Error in the program’s algorithm – Most difficult to diagnose – Computer does not recognize it.
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 25
Program Errors
(cont.)
Syntax error example
x = 2; y = 3 z = x + y;
This line consists an error. Each statement must be ended with a semi-colon ‘;’
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 26
Program Errors
(cont.)
Run-time error example
x = 0; y = 3/x;
This line produces an error, because the division by zero. This error is only discovered when the program runs.
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 27
Program Errors
(cont.)
Logic error example
Enter a number >>
10
Enter another number
>> 25
The
total
of those two numbers is
15
This is a logic error. The total should be 35 not 15.
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 28
Program Design • Structure Chart • Pseudo-code • Flowchart
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 29
Structure Chart
Represents a program as a collection of sub-programs (modules) Example:
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 30
Pseudo code
Describe an algorithm in English-like statements Example: Algorithm for multiplying two numbers 1. Get the first number, let say A 2. Get the second number, let say B 3. Calculate the result let say C, C= A * B 4. Display the result, C
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 31
Flowchart
Represents an algorithm in graphical symbols
Example: Algorithm for multiplying two numbers Start Get A Get B Calculate Resut C=A*B Display the Result C Stop
Chapter 1: Introduction To Computer
| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005
Slide 32