Chapter 1 Intro To CP
Chapter 1 Intro To CP
BDA 24202
DR. HO FU HAW
JKP, FKMP
E5-001-10
ABOUT THIS COURSE
• Engineering Knowledge - Apply the problem solving technique using algorithm and
construct the structure of program as awareness and basic understanding in
programming language. (C3, LO1, LOD1)
• Modern Tool Usage-Develop the program to solve problem using C language. (C4,
LO2, LOD9)
• Life Long Learning-Present the project findings in oral and written form for the
individual or group assignment (A2, LO6, LOD13)-Present the project findings in oral
and written form for the individual or group assignment (A2, LO6, LOD13)
CONTENTS
• 1.0 INTRODUCTION TO COMPUTER AND PROGRAMMING
• Introduction To Computer And Programming, Flow Chart and Pseudo Code.
• 2.0 THE STRUCTURE OF C LANGUAGE
• Introduction to C language, Basic C, Function Variable, Constant and Identifier, Data Types,
Pre-processor Directives.
• 3.0 INPUT AND OUTPUT DATA
• Input/Output String Processing, File Processing.
• 4.0 OPERATORS AND EXPRESSIONS
• Mathematical Operators, Conditional Operators, Relational and Logical Operators,
Assignment Operators.
• 5.0 CONTROL STATEMENTS
• Using control statement which includes if, for, switch, while loop, break, and goto.
• 6.0 ARRAYS
• Array, multidimensional array, pointer, string.
• 7.0 FUNCTIONS
• Definition, Accessing A Function, Function Types, Function Prototypes, Function Call
• 8.0 EMBEDDED SYSTEMS PROGRAMMING (2 hours)
• Concept of Embedded Systems Programming, Embedded Systems Interfacing, Design
Integration of Software and Hardware
ASSESSMENT
• Stya, P. (2015). Programming in C, New Delhi: I K International Pvt Ltd. Call number:
QA76.73.C153.P72 2015
• Mike, M. (2012). C Programming in easy steps, Warwickshire: In Easy Steps. Call number: QA76.73.
M47 2012
WHY YOU NEED PROGRAMMING SKILLS?
• JOB REQUIREMENTS
• INDUSTRY REVOLUTION 4.0 (IoT, AI, Big Data, Embedded Engineering)
• HIGHER SALARY
• OTHERS.
CHECK HERE: TOP 10 PROGRAMMING LANGUANGES
EXAMPLES OF PROGRAMMING APPLICATIONS
• C/C++
• JAVA
• ALGOL
• PYTHON
• VISUAL BASIC
• FORTRAN
OFF-LINE AND ON-LINE C-COMPILER
HOW DO YOU WRITE A PROGRAM?
• The pseudocode from the previous slide would look like this as a flowchart:
Start
Display c
Get number a
and b
End
C = a+b
WHAT ARE THOSE FUNNY SYMBOLS?
• START/END
• INPUT/OUTPUT
• PROCESS
• DECISION
• START/END Start
End
• INPUT/OUTPUT
• Shows when
information/data comes
into a program or is
printed out.
• PROCESS
• Used to show calculations,
storing of data in
variables, and other
“processes” that take place
within a program.
• DECISION
• Used to show that the
program must decide
Y
whether something (usually X>7?
a comparison between
numbers) is true or false. N
YES and NO (or T/F)
branches are usually
shown.
FLOWCHART
DO…WHILE LOOP IN WHILE….LOOP IN
PSEUDOCODE PSEUDOCODE
1. GET X 1. GET X
2. DO 2. WHILE (X<20)
Y= X + 2 Y= X + 2
WHILE (X<20) 3. DISPLAY Y
3. DISPLAY Y 4. END
4. END
Y= X +2
X<20
X<20
Y=X+2
EXERCISES 1.0:
• Develop a flow chart of y=(x+y)*(z+y) numbers, and convert the
flowchart into pseudo code
• Develop a flow chart to decide if no rain you will come to class by
bicycle, else you will come to class by bus.
• Develop a flow chart to evaluate z, if x=12y, z=x+5.
• Develop a flow chart to score marks for your individual and group
project to enable you to get at least grade B+ in C-Programming
course (assuming you obtain 10% in both test 1 and test 2, 8% in
both lab test 1 and 2, Individual project: unknown, group project:
unknown)
EXERCISE 2.0:
• Computing Weekly Wages: Gross pay (Y) depends on the pay rate
and the number of hours worked per week. However, if you work
more than 40 hours, you get paid 1.5 rate for all hours worked over
40. Assume pay rate/hour = RM5, X = total hour(s).
a. Develop a flow chart to display above weekly wages calculation.
b. Construct the Pseudo-code based on the developed flow chart.
LOOPS
2𝑥 + 5 ; 𝑥 ≤ 5
𝑓 𝑥 =
12𝑥 + 𝑥 2 ; 𝑥 > 8
EXERCISE 5.0:
x 2 3x + 2 for 0 x < 1.5
f (x) = x-4 x+1 for 1.5 x < 3.0
2x + 5
for 3 x < 5.0
Log10 x 2 1
• If a long x = 0 to x = 5.0, let define xi, i = 1, 2, 3, …., N. where
dx is distance between two successive point xi and xi+1 is equal to
0.01+x.
• Write the flowchart and pseudocode, so the program will find the
maximum value of f(x)
EXERCISE 6.0:
PLEASE DRAW THE FLOW CHART AND PSEUDO CODE
FOR BELOW CASE
• If projectile with initial velocity u (m/sec) is fired at angle θ(with horizontal),
then the horizontal range R is given by R =u2sin 2θ/g where g =9.81 m/sec2.
Draw a flowchart to compute each value of R when u varied from 20-150
m/s and 400 to 500 m/s at θ=50° .
EXERCISE 7.0:
DEVELOP A FLOW CHART FOR BELOW CASE:
• A ball was dropped from a 100m tall building, the initial speed U is 10 m/s.
The acceleration of ball is R= 2UHg/5, H is the height of building, g is the
gravity. Draw a flow chart to determine the acceleration of ball
a. height H= 90m
b. 70m<H<65m
QUESTION?
•THANK YOU……..