ent 189 c programming
TRANSCRIPT
-
8/19/2019 Ent 189 C programming
1/47
ENT 189
COMPUTER PROGRAMMING
Dr. Lam Chee Kiang
Email: [email protected]
Room: #44 (MEKA 3, 2nd Floor, BesidesMKM 1)
Pn. Humairah Binti Mansor
-
8/19/2019 Ent 189 C programming
2/47
Dr. PAULRAJ M P, Associate Professor,
School of Mechatronic Engineering,#42- Level 2,Ulu Pauh New Campus02600-Arau.
PERLIS
Email: [email protected] H/P: 017 5103757Home page: http://publicweb.unimap.edu.my/~paul/
ENT 189: COMPUTER PROGRAMMING
-
8/19/2019 Ent 189 C programming
3/47
Course Outcomes
CO1 : Ability to define the basic programming
techniques.
CO2: Ability to apply suitable programmingtechniques to solve a given problem.
CO3: Ability to develop and analyze computer programs in C and C++ for Mechatronic
Applications.
-
8/19/2019 Ent 189 C programming
4/47
General Information
Contributes 3 units:
2 hours - lectures
2 hours –
lab and tutorial
Main Objective:
Students can independently write acomputer program to solve problemsrelated to engineering.
-
8/19/2019 Ent 189 C programming
5/47
Project : Team (Two/Three)
Evaluation Contribution
Examination:Mid Examination : 10%Final Examination : 60%
Course Work:Lab : 10%Lab Test : 5%Mini Project : 15%
-
8/19/2019 Ent 189 C programming
6/47
Lecture content can be accessed through
http://publicweb.unimap.edu.my/~paul/
Lecture Content
-
8/19/2019 Ent 189 C programming
7/47
References
C How to program, Deitel, Suhizaz,
R Badlishah, Yasmin, Pearson Prentice Hall
Beginning Visual C++”, Ivor Hortons, Wiley
Publishing, Inc Indiana 2003.
“C Programming for Engineering & ComputerScience ”, H.H.Tan and T.B.Orazio, Mc Graw
Hill, 1999. Any other C programming books
-
8/19/2019 Ent 189 C programming
8/47
INTRODUCTION TO COMPUTER SYSTEMS
It is a collection of
Instructions.Software
Hardware
It is a Physical Equipment.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
9/47
HARDWARE COMPONENT
1. Input Devices
2. Central Processing Unit
(CPU)
3. Primary Storage
4. Output Devices
5. Auxiliary Storage Devices
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
10/47
INPUT DEVICE
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
11/47
Hardware: Physical Component
Input Device
Through which programs anddata are entered.
Key Board, Mouse, a pen orstylus, a touch screen.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
12/47
Central Processing Unit (CPU)
Responsible for executing instructions suchas arithmetic calculations,comparisons
among data and movement of data inside the
system.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
13/47
-
8/19/2019 Ent 189 C programming
14/47
OUTPUT DEVICE
To show the processed resultoutput devices are used.If the output is shown in amonitor it is called soft copy.
If it is printed on the printer,it is called as hard copy.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
15/47
AUXILIARY STORAGE
It is the place whereall the programs anddata are stored
permanently.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
16/47
SOFTWARE
System
Software
It manages the computer
resources. It provides aninterface between thehardware and the users butdoes nothing to directly
serve the users.EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
17/47
COMPUTER PROGRAM
It is a sequence of instructions used to
perform a job.
Programming is the process of writing the
instructions in a language that thecomputer can understand.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
18/47
PROGRAMMING LANGUAGE
The set of instructions that can be used toconstruct a program is called aprogramming language
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
19/47
COMPUTER LANGUAGES
MACHINE LANGUAGE
Made up of ‘0’ s and ‘1’ s Example: 00110011 is aninstruction SYMBOLIC LANGUAGE
Mnemonics are used to denote
the strings of ‘1’s and ‘0’s. Example: ADD A
HIGH LEVEL LANGUAGESWorking with symbolic language is verydifficult.To improve programmer’s efficiency High levellanguages are developed.HLL are portable.HLL relieve the programmer from the
assembly language
-
8/19/2019 Ent 189 C programming
20/47
HIGH LEVEL LANGUAGES
i) FORTRAN – FORmula TRANSlationCreated by John Backus in 1957Used for Scientific and Engineering applications.
ii) COBOL – Common Business Oriented LanguageDeveloped by Admiral hopper
iii) C – Middle level languageDeveloped by Dennis Ritchie at AT&T Bell Laboratoriesof USA in 1972.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
21/47
HOW TO FEED YOUR PROGRAM TO A COMPUTER?
A text editor is used to Enter, Modify and Save the
programs and data.Some of the text editors are available with searchcommands to locate and replace statements, copy andpaste commands to copy or move statements from onepart to another.
The programs written and saved will be input to thecompiler. The program is known as source program.
COMPILER
Compiler is a program that converts source programinto machine language. A C compiler contains two separate programs as :preprocessor and translator.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
22/47
A preprocessor search for the preprocessor directives(special commands) and make substitutions of code. Afterthe preprocessor has prepared the code for compilation,the translator converts the program into machine language
and this code is called object code.
PREPROCESSOR
Even though the output of the compiler is machine
language, it can not be executed. The object code islinked to the library functions using the linker and aexecutable code is produced. The final executableprogram is executed in the system.
LINKER
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
23/47
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
24/47
To execute your program, use an operating system, loadyour program in the primary memory and execute it. Theprogram is loaded into the primary memory using a
system program called Loader.
PROGRAM EXECUTION
-
8/19/2019 Ent 189 C programming
25/47
PROBLEM SOLVING
DEFINE THE PROBLEM
LOOK AT POTENTIAL CAUSES FOR THEPROBLEMSELECT AN APPROACH TO RESOLVE THEPROBLEM
IDENTIFY ALTERNATIVES FOR APPROACHESTO RESOLVE THE PROBLEM
PLAN THE IMPLEMENTATION OF THE BEST ALTERNATIVE
MONITOR IMPLEMENTATION OF THE PLAN
VERIFY IF THE PROBLEM HAS BEENRESOLVED OR NOT
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
26/47
TOOLS TO DEVELOP THE SOLUTION
STRUCTURECHARTS
Used to design the whole program, It isalso known as hierarchy chart. This chartshows the functional flow of the inter-
related components. The structure chartshows how you are going to break yourprogram into logical steps; each step willbe a separate module. It also shows theinteraction between various modules.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
27/47
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
28/47
English – like statements thatfollow a loosely defined syntax areused to convey the design of thealgorithm.Example: Pseudo code to add
three number and to display theaverage:Step 1: Input three numbers intothe computer.
Step 2: Add all the three numbersand divide it by 3.Step 3: Display the result asaverage.
PSEUDO CODE
Example:
input Ainput BC = A + Bprint C
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
29/47
FLOW CHART
It is a program design tool in which standard graphicalsymbols are used to represent the logical flow of datathrough a function. A flowchart is a diagrammatic representation thatillustrates the sequence of operations to be performed toget the solution of a problem. Flowcharts are generallydrawn in the early stages of formulating computersolutions. Flowcharts facilitate communication betweenprogrammers and business people. These flowcharts are
quite helpful in understanding the logic of complicatedand lengthy problems. Once the flowchart is drawn, itbecomes easy to write the program in any high levellanguage.
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
30/47
Terminal
Input/Output
Process
Flow Lines
Decision
Loop
PredefinedProcess
Connector
-
8/19/2019 Ent 189 C programming
31/47
-
8/19/2019 Ent 189 C programming
32/47
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
33/47
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
34/47
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
35/47
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
36/47
TESTING THE PROGRAMS
Program testing is very tedious and time consuming part of
program development. There are two type of programtesting
In this method of testing, the
program is tested withoutknowing what is inside theprogram. ie., The program is likea black box that we can not see.
In this method, the tester knowseverything about the program. Inthis case program is like a glasshouse in which every thing is
visible.
BLACK BOX TESTING
WHITE BOX TESTING
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
37/47
Control Structure
All programs could be written in terms ofthree control structures:
Sequence structure
Selection structure
Repetition structure
-
8/19/2019 Ent 189 C programming
38/47
Sequence structure
Is a series of steps executed sequentiallyby default
Read num1,num2
Calculatetotal=num1+num2
Print total
Pseudocode Flowchart
Read num1,num2
total = num1+num2
print total
-
8/19/2019 Ent 189 C programming
39/47
Selection structure
Used to choose among alternative coursesof action
C has three types: if , if ..else, and switch
-
8/19/2019 Ent 189 C programming
40/47
The if selection structure
if structure is a single-entry/single-exitstructure
true
false
grade >= 60 print “Passed”
If student’s grade is greater than or equal to
60
Print “Passed”
-
8/19/2019 Ent 189 C programming
41/47
The if..else selection structure
Specifies an action to be performed bothwhen the condition is true and when it isfalse.
truefalse
print “Failed” print “Passed”
grade >= 60
If student’s grade is greaterthan or equal to 60
Print “Passed” else
Print “Failed”
-
8/19/2019 Ent 189 C programming
42/47
Repetition structure
Specifies a block of one or morestatements that are repeatedly executeduntil a condition is satisfied
Three types : while, for,
do-while
Th hil titi
-
8/19/2019 Ent 189 C programming
43/47
The while repetitionstructure
Programmer specifies an action is to berepeated while some conditions remains true
product
-
8/19/2019 Ent 189 C programming
44/47
END OF LECTURE-1
EKT120 Computer ProgrammingDr.Paulraj M P, School of Mechatronics Engineering, KUKUM
-
8/19/2019 Ent 189 C programming
45/47
AN Y QUES TIONS?
-
8/19/2019 Ent 189 C programming
46/47
THANK YOU
-
8/19/2019 Ent 189 C programming
47/47
List of Experiments
1. C Programming Environment.
2. Logical and repetitive structurestatements.3. Functions and Pointers.4. Structure and File handling methods.
Click to return