Computer Programming BDA 24202: Prepared By: Dr. Ho Fu Haw
Computer Programming BDA 24202: Prepared By: Dr. Ho Fu Haw
BDA 24202
• 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
• Concept of Embedded Systems Programming Embedded Systems Interfacing, Design
,
• 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
whether something (usually Y
X>7?
a comparison between
numbers) is true or false. N
YES and NO (or T/F)
branches are usually
shown.
FLOWCHART SYMBOL SUMMARY
FLOW CHART EXAMPLES
LOOPS- ITERATION (REPETATION)
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+2)*(z+3) 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=12, z=x+5.
DEVELOP A FLOW CHART OF Y=(X+2)*(Z+3) 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=12, z=x+5.
EXERCISE 2.0:
• Computing Weekly Salary: Gross pay (Y) depends on the pay rate
and the number of hours (X) worked per week. However, if you work
more than 40 hours, you will 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 salary calculation.
b. Construct the Pseudo-code based on the developed flow chart.
Start Pseudo Code:
1. Start
Get 2. Get Hours (X)
Hour(X) 3. If X>40
Y=Y=(40*5)+(X-40)*5*1.5
else
No
Y=X*5
X>40 Y=X*5 4. Display Y
5. End
yes
Y=(40*5)+(X-
40)*5*1.5
Display Y
End
EXERCISE 3.0:
1. Start
X=0 2. X=0
3. If x<=2;
X=X+0.2 Y=5*x+(x*x);
X=X+0.2;
No Display y;
X<=2 else
Display Y;
yes 4. End
Y=5*x+(x*x)
Display Y
End
EXERCISE 4.0:
DEVELOP A FLOW CHART FOR BELOW FUNCTION
2𝑥𝑥 + 5 ; 𝑥𝑥 ≤ 5
𝒇𝒇 𝒙𝒙 = �
12𝑥𝑥 + 𝑥𝑥 2 ; 𝑥𝑥 > 8
Start Pseudo Code:
1. Start
Get X 2. Get X
3. If x<=5;
f(x)=2*x+5;
display f(x);
X<=5 f(x)=2*x+5 elseif
yes x>8;
No f(x)=12 ∗ 𝑥𝑥 + x ∗ x;
display f(x);
else
X>8 f(x)=12 ∗ 𝑥𝑥 + x ∗ x End
yes 4. End
No
Display
f(x)
End
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 + 1
2
)
• If a long x = 0 to x = 5.0, the increment is of x = x+0.5
• Write the flowchart to display all x value.
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° .
Start • If projectile with initial velocity U
(m/sec) is fired at angle θ(with
G=9.81; θ=0; R=0; U=0 horizontal), then the horizontal range
R is given by R =u2sin 2θ/g where g
No =9.81 m/sec2. Draw a flowchart to
θ=50 compute each value of R when U
varied from 20-150 m/s and 400 to
yes
yes 500 m/s at θ=50° .
20<=U>=150 R =u2sin 2θ/g
No
Display R
End
QUESTION?
•THANK YOU……..