1 ept 162 introduction
TRANSCRIPT
-
8/10/2019 1 EPT 162 Introduction
1/12
1
SELAMAT DATANG
UNIVERSITY MALAYSIA PERLIS
School of Manufacturing Engineering
2
Dr Azuwir Mohd Nor
Dr Mohd Sazli Saad
Dr Azuwir Mohd Nor
Dr Mohd Sazli Saad
EPT 162
Computer Programming
Monday 8.00 am- 11.00 a.m. MPU 2
Lecture/Lab/Tutorial
Instructor
Dr Azuwir Mohd Nor Room: MPU 7Dr Mohd Sazli Saad Room: MPU8
4
EXPECTATION
YOUR COMMITMENT TOWARDS STUDY
YOU ARE UNIV STUDENTS
FULL ATTENDANCE
DO A LOT OF INDEPENDENCE STUDY
SELF LEARNING
INFORMATION SEARCH
READING
BE PREPARED BEFORE COMING TO
CLASS
-
8/10/2019 1 EPT 162 Introduction
2/12
5
General Information
Main Objective:
Students can independently write, compile,debug and execute computer programs tosolve problems, especially engineeringrelated problems.
Teaching Plan
PEO & PO
6
Evaluation
Exams:
Midterm exam => 20%
Final Exam => 50%
Lab reports => 15%
Assignment/Quiz=> 15%
Assignments are assessed individually & In Group
The two tests are written test/Lab test
7
References
Hanly, J.R. and Koffman, E.B., C ProgramDesign for Engineers, 2nd Ed., Addison-Wesley,2001.
ISBN : 0321204174
Deitel & Deitel, Suhizaz Sudin, R. Badlishah andYasmin Yacob, C How To Program, Pearson-Prentice Hall, 2006.
Tan, H.H. and DOrazio,T.B., C Programming forEngineering & Computer Science, Mc Graw Hill,
1999.
8
Today Outline Computer Fundamentals
Computer organization and hardware
Computer software
Programming LanguagesMachine language
Assembly language
High-level language
Algorithm : pseudo code and flowchart Control Structures
Simple C Program
-
8/10/2019 1 EPT 162 Introduction
3/12
9
Computer Fundamentals
Computer system is divided into hardwareand software.
Hardware refers to physical components ofcomputer which are:
Main Memory
Central Processing Unit (CPU)
Input Device
Output Device
Secondary Memory Device
1-10
1-11
Components of a ComputerThe latest Intel microarchitecture on the 22 nm
manufacturing process delivers significant performance
advancementsincluding vastly improved graphics,
battery life, and securityfor a zero-compromise
computing experience.
12
With key features such as Intel
Hyper-Threading Technology, that
allows each processor core to work on
two tasks at the same time for greater
multitasking, to the Intel Iris
graphics for stunning 3-D visuals and
faster, more advanced video and photo
editing, the 4th generation Intel
Core i7 processor delivers top-of-
the-line performance for your most
demanding tasks.
-
8/10/2019 1 EPT 162 Introduction
4/12
13
Computer Hardware
Input Device Output Device
Secondary Memory
Control Unit
Arithmetic andLogic Unit
Register
CPU
Main Memory
14
Central Processing Unit (CPU)
CPU is the computers administrator and isresponsible for supervising the operation of theother sections
Consists of two functional units; control unitand arithmetic-logic unit (ALU)
Control unit supervises all activities of thecomputer system
ALU performs basic arithmetic operations andcomparison operations
15
Main Memory
keeps information from the input unit
also keeps processed information until itcan be placed on output devices
all programs must be loaded into mainmemory before they can be executed andall data must be brought into main memory
before it can be manipulated.
16
Main Memory
Main memory can be further classifiedinto two types:Random Access Memory (RAM)
information in RAM will be lost when thecomputer is turned-off.
Read Only Memory (ROM) It has been set during manufacturing process.
ROM usually contains instructions and
information considered to be fundamental tothe computer.
-
8/10/2019 1 EPT 162 Introduction
5/12
1-17
1000 Memory Cells in
Main Memory
18
Secondary Memory
Main memory is only used during
processing following certain instructions
Permanent information is NOT stored inmain memory but is stored in secondarymemory
E.g. program file, data fail, etc
E.g. hard disk, diskette, CD
1-19
Secondary Storage Media
20
Input/Output Devices
Input devices - feed data and programsinto computers
E.g. keyboard, mouse, touch screen,scanners
Output devices - display results produced
by computerE.g. monitor, printer, speaker
-
8/10/2019 1 EPT 162 Introduction
6/12
21
Software
As a complement to hardware, computer
system needs software to solve problems.
Software are classified into :
System software
Application software
22
Software
System software : manages the computer andits peripheral devices (hardware)
E.g. Operating system (OS)
Text editor
Pre-processor
Language translator
Linker
Loader
Compiler: reads something.c source, writes something.o object.Linker: joins several *.o files into an executable program.Loader: code that loads an executable into memory and starts itrunning.
23
Software
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 publishingsoftware, spreadsheets, database, graphics,communication, programs perform specific taskssuch as accounting, scientific, engineering,education, etc
24
Programming Languages
Programming language is divided intothree categories:
Machine Language
Assembly Language
High-Level Language
-
8/10/2019 1 EPT 162 Introduction
7/12
25
Machine Language
Language understood by the computer
Bunch of 0s and 1s
Program written in machine language can beexecuted without being translated
Nevertheless, hard to learn because it is writtenin 0s and 1s
Program is too long to solve simple problem
Machine-dependant and not portable E.g.
0101 0001 1100 0100 1011 1000
0101 1000 0101 1001 1100 0111
1-26
Relationship Between a Byte and a Bit
27
Assembly Language
Strings of 0s and 1s are replaced intoinstructions which resemble Englishlanguage to represent computer operationelement
Easier to understand and write
E.g. LOAD rateMULT hourSTOR wages
28
Assembly Language
Nevertheless, needs language translatorcalled Assembler to change AssemblyLanguage to Machine Code for executionpurpose
still too long and not portable
-
8/10/2019 1 EPT 162 Introduction
8/12
29
High-Level Language
Improves weaknesses in Machine Languageand Assembly Language
Portable
Written in one instruction to carry out severalinstructions in machine level E.g. discount_price = price discount;
Must be changed to machine code beforeexecuted, needs compiler: a system softwarethat translates source program to object program
30
Algorithms a process or set of rules to be followed in calculations
or other problem-solving operations, especially by acomputer.
The solution to any computing problem involvesexecuting series of actions in a specific order
Pseudo code : artificial and informal language thathelps programmers develop algorithms
E.g.
if students grade is greater than or equal to 50Print Pass
else
Print Fail
31
Algorithms
Flowchart: visual-form of an algorithm
E.g.
Process 2Decision
Data
Process 1
Begin
End
32
Algorithm-Basic symbols in aflowchart
Start/End
Process
Input/Output
Decision
Flowdirection
Connector
-
8/10/2019 1 EPT 162 Introduction
9/12
33
34
Pseudo code
Begin
Input A and B Calculate A + B
Print result of SUM End
Begin
Input
A,B
Calculate
A + B
Print SUM
End
35
Control Structure
All programs could be written in terms ofthree control structures:
Sequence structure
Selection structure
Repetition structure
36
Sequence Structure
Is a series of steps executed sequentiallyby default
Read num1, num2
Calculate total=num1+num2
Print total
Pseudo code Flowchart
Read num1, num2
total = num1+num2
print total
-
8/10/2019 1 EPT 162 Introduction
10/12
37
Selection Structure
Used to choose among alternative courses
of action
C has three types: if, if..else, andswitch
38
The if Selection Structure
if structure is a single-entry/single-exit
structure
true
false
grade >= 60 print Pass
If students grade is greater than or equal to 60
Print Pass
39
The if..else Selection Structure
Specifies an action to be performed bothwhen the condition is true and when it isfalse
truefalse
print Fail print Pass
grade >= 60
If students grade is greater
than or equal to 60
Print Pass
else
Print Fail
40
Repetition Structure
Specifies a block of one or morestatements that are repeatedly executeduntil a condition is satisfied
Three types : while, for,
do-while
-
8/10/2019 1 EPT 162 Introduction
11/12
41
The while Repetition Structure
Programmer specifies an action is to berepeated while some conditions remain true
product
-
8/10/2019 1 EPT 162 Introduction
12/12
45
Simple C Program: Program to add two numbers
#include
int main(void){
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
46
Any Question?
Reading assignment: Find out...
Data types?
Variables?
Arithmetic operators
Relational and Logical Operators
Reference
EKT 120 notes, School of Computer &Communication, UNIMAP.
Hanly & Koffman, C Program Design forEngineers. Addison Wesley, 2nd Edition,2001.
47