Beruflich Dokumente
Kultur Dokumente
CHAPTER 1
INTRODUCTION TO COMPUTER
PROGRAMMING
(Part 1)
Lecturer: Mrs Nurul Izni Rusli
nurulizni@unimap.edu.my
UNICITI S2 BK5 Level 1
Course Synopsis
One of the aspects of a good engineer is to have the capability of
integrating the hardware and the software, thus an electrical engineer
should be competence in programming.
This course introduces basic programming using high level language (C
language).
programming,
familiarize with the programming tools such as organization chart,
Course Outcomes
CO1:
Evaluation Contribution
Final Exam
Midterm Exam
10%
Laboratory
10%
40%
20%
20%
PLT101 2013/2014
Mini Project
Assignment
References
Deitel P. and Deitel H., C How to Program. 7th Edition. New Jersey: Pearson-
Outline
Computer Fundamentals
Computer organization and hardware
Computer software
Programming Languages
Machine language
Assembly language
High-level language
Computer Fundamentals
Computer
software.
Hardware refers to physical components of computer
which are:
Main Memory
Components of a Computer
CPU
Control Unit
Input Device
Arithmetic and
Logic Unit
Register
Main Memory
Secondary Memory
10
Output Device
Figure 1.2
Hardware Architecture
system
Arithmetic-logic unit (ALU) - performs basic arithmetic
operations and comparison operations
Registers - fast memory
11
Figure 1.3
The Intel Atom processor chip contains the full circuitry of a central
processing unit in an integrated circuit whose small size and low power
requirements make it suitable for use in mobile internet devices. (Intel
12
Main Memory
Keeps information from the input unit for rapid access.
Also keeps processed information until it can be
13
turned-off.
Read Only Memory (ROM)
It has been set during manufacturing process. ROM usually
14
Figure 1.4
1000 Memory Cells in Main Memory
15
Secondary Memory
Main memory is only used during processing
16
17
Input/Output Devices
Input devices - feed data and programs into
computers
E.g. keyboard, mouse, touch screen, scanners
by computer
E.g. monitor, printer, speaker
18
19
Software
As a complement to hardware, computer
20
Software cont.
System software : manages the computer and its
21
Software cont.
Application software : performs specific tasks
There are TWO types:
Program to solve specific problems
Program written by user to solve specified problem
E.g. word processor, desktop publishing software,
Programming Languages
Programming language is divided into THREE
categories:
Machine Language
Assembly Language
High-Level Language
23
Machine Language
Language understood by the computer
Bunch of 0s and 1s
Program written in machine language can be executed
1s
25
Assembly Language
Strings of 0s and 1s are replaced into instructions
26
LOAD
MULT
STOR
rate
hour
wages
27
High-Level Language
Improves weaknesses in Machine Language and
Assembly Language
Portable
Written in one instruction to carry out several
Algorithms
Example:
if students grade is greater than or equal to 50
Print Pass
else
Print Fail
29
Algorithms cont.
Flowchart: visual-form of an algorithm
Example:
Begin
Data
Process 1
Decision
End
30
Process 2
Start/End
Process
Input/Output
Decision
31
Flow
direction
Connector
Flowchart (Example)
Start
sum=num1+num2
print sum
End
32
TRY THIS!!!
Write a pseudo code, flowchart
and program that calculates and
prints the SUM of two integers A
and B.
Pseudo code
Begin
Input A and B
Calculate A + B
Print result of SUM
End
Flowchart
Begin
Input
A,B
Calculate
A+ B
Print SUM
End
33
34
Figure 1.8
Entering, Translating, and Running a HighLevel Language Program
35
Simple C Program:
Program to add two numbers
#include <stdio.h>
int main()
{
int A, B, Sum;
printf (input first integer \n);
scanf (%d, &A);
printf (input second integer \n);
scanf (%d, &B);
Sum = A + B;
printf (Sum is %d\n, Sum);
return 0;
}
OUTPUT
Input first integer
39
Input second integer
27
Sum is 66
37
3
8