bab 1 - introductory concepts
TRANSCRIPT
-
8/3/2019 Bab 1 - Introductory Concepts
1/25
Course Lecturer:Pn Norhayati bt Jais
Correction and rewrite:
Norzaiwin B Zainal Abidin
-
8/3/2019 Bab 1 - Introductory Concepts
2/25
Define programme, programmer andprogramming language
Types of programming language
Types of programming: Structured programming
Modular programming
Object-oriented programming
-
8/3/2019 Bab 1 - Introductory Concepts
3/25
List stages involved in problem solving
Elements of problem analysis : Input, Process,Output
Design tools for problem solving: Flowchart
Pseudo code
IPO Chart (Input-Process-Output Chart)
Types of error in programming: syntax error,
run-time error & logical error
-
8/3/2019 Bab 1 - Introductory Concepts
4/25
ProgrammeProgrammeProgrammeProgramme - A set of instructions that tells
the computer what to do ProgrammerProgrammerProgrammerProgrammer A person who is involved in
the programming phases.
Programming languageProgramming languageProgramming languageProgramming language is the languageunderstood by the computer, used to tellthe computer what to do.
-
8/3/2019 Bab 1 - Introductory Concepts
5/25
Machine languagesMachine languagesMachine languagesMachine languages is a true computer language
machine specific instructions, consists of binarynumbers i.e 0 and 1.
lowest level representation of computer program
Assembly languagesAssembly languagesAssembly languagesAssembly languages
Using mnemonics to represent machine languageinstructions (translated via assemblers)
Example:mov ax, 1234h (mov value 1234h intoregister ax)
HighHighHighHigh----level languageslevel languageslevel languageslevel languages Codes similar to everyday English
Use mathematical notations (translated via compilers)
Example: grossPay = basePay + overTimePay
-
8/3/2019 Bab 1 - Introductory Concepts
6/25
Structured Programming
Computer programming in which the statements are organized in aspecific manner to minimize error or misinterpretation.ALGOL, Pascal, C, PL/I andALGOL, Pascal, C, PL/I andALGOL, Pascal, C, PL/I andALGOL, Pascal, C, PL/I and AdaAdaAdaAda....
Functional / Modular Programming
Modular programming is subdividing program into separatesubprograms such as functions and subroutines. make programshorter, hence easier to read and understand.
Scheme, LISPScheme, LISPScheme, LISPScheme, LISP Object Oriented Programming (OOP)
A computer programming methodology that focuses on datarather than processes, with programs composed of self-sufficientmodules (objects) containing all the information needed to
manipulate a data structure. Abbreviated OOP.Java, C++Java, C++Java, C++Java, C++
-
8/3/2019 Bab 1 - Introductory Concepts
7/25
Problem requirements
Problem Analysis Program Design (Algorithm)
Writing Programme
Testing and debugging Documentation
-
8/3/2019 Bab 1 - Introductory Concepts
8/25
Before any problem can solve, we
really have to understand what isto be solve.
To understand, we should thinkand ask question
1. Problem Requirements
-
8/3/2019 Bab 1 - Introductory Concepts
9/25
All computer programs have several
elements in common. Input
Process
Output
They receive data input from users, storethe data on some storage device (e.g. harddisk), process the data into useful
information, and finally produce output inthe form of reports. (Figure 1)
2. Problem Analysis
-
8/3/2019 Bab 1 - Introductory Concepts
10/25
S T O R A G E
I
N
P
UT
PR
O
C
E
S
S
O
U
T
P
UT
-
8/3/2019 Bab 1 - Introductory Concepts
11/25
Identify and understand the problem to be
solved. Problem analysis is done by determining 3
main things: InputInputInputInput needed
OutputOutputOutputOutput has to be produced
ProcessProcessProcessProcess to be carried out in order to get the outputbased on the input
INPUTINPUT OUTPUTOUTPUTPROCESS
(programme)PROCESS
(programme)
2. Problem Analysis
-
8/3/2019 Bab 1 - Introductory Concepts
12/25
Better known as Algorithm
Algorithm is a list of sequential steps tosolve a problem
2 methods in writing algorithm :
Pseudo Code
steps in problem solving (logic)written using a combination of spoken languageand some programming language semiformal.
Flow Chart steps in problem solving (logic)
using diagrams and specific symbols.
-
8/3/2019 Bab 1 - Introductory Concepts
13/25
Pseudo Code steps in problem solving (logic)written using a combination of spoken language
and some programming language semiformal. Example:
Begin
Read aRead b
Count y=a*bWrite y
End
** PSEUDO CODEPSEUDO CODE
-
8/3/2019 Bab 1 - Introductory Concepts
14/25
**** Flow Chart SymbolsBEGIN / END
PROCESS
INPUT / OUTPUT
DECISION
CONTINUE
ACTIVITY FLOW
-
8/3/2019 Bab 1 - Introductory Concepts
15/25
Implementation phase, where the code iswritten and typed using the computer
A logic problem solving represented bypseudo codes dan flow chart converted tocomputer programme, using suitable
language
Language example: C, C++, Visual Basic,Java, PHP
-
8/3/2019 Bab 1 - Introductory Concepts
16/25
Program that have been complete, has to beteated/runto make sure the output iscorrect.
Debugging that is by inserting true data tobe tested
If there is an error, correct it, depend onwhich error.
-
8/3/2019 Bab 1 - Introductory Concepts
17/25
There tree types of error.
Logical Error due to ways of solving andsteps is not correct and the flow is not logic. Syntax Error due to syntax statement is
not correct according to program language
used. Run-time Error due to input data is not the
input of the program required.
-
8/3/2019 Bab 1 - Introductory Concepts
18/25
This the last steps, preparing a report for
future upgrading and correction. Document consists: Types of problem or a true specific requirement Types of input, output, constraint and formula
for the problem. Logic algorithm used such as flow chart or
pseudo code Example of output executed using test data. Steps or guidance of using a program
-
8/3/2019 Bab 1 - Introductory Concepts
19/25
Define & Analyst Problemo Define & knowing problems
o
Define data problems
input & output
Program Design
o Plan & fixed strategyo Knows data model,
component & relation
o Build algorithm/ flowchart
Code the programTranslate the algorithm into
program code using the
specific programming
language
Test Programo Test the program using
computer for errors.
o Correct output as define by
user.
Prepare documentationo Problem analysis document
and program and modules
involve
CorrectProgram
Error
-
8/3/2019 Bab 1 - Introductory Concepts
20/25
THE PROBLEMTHE PROBLEMTHE PROBLEMTHE PROBLEMA durian seller like to calculate the cost of thedurian the customer have to pay. If the durian
cost RM2.50 per kilogram. Program a way forcalculating the total cost of durians for anamount in kilogram of durians sell.
-
8/3/2019 Bab 1 - Introductory Concepts
21/25
Defination & Analising ProblemDefination & Analising ProblemDefination & Analising ProblemDefination & Analising Problem
Understand the problem:Understand the problem:Understand the problem:Understand the problem: List the facts from the problem:
Price of a kilogram of durian is RM2.50 Additional information needed is the weight of
durian in Kilogram.
The total cost of durian Analising the problemAnalising the problemAnalising the problemAnalising the problem:
Define the input, output and the proces.
TotalWeight
(Kg)
CostCost = Total
weigrt xRM2.50
-
8/3/2019 Bab 1 - Introductory Concepts
22/25
Design the AlgorithmDesign the AlgorithmDesign the AlgorithmDesign the AlgorithmPseudo code:Pseudo code:Pseudo code:Pseudo code:Begin:Input:read the total weight
Proses:calculate cost :
cost = total weight x 2.50Output:display cost
End.
-
8/3/2019 Bab 1 - Introductory Concepts
23/25
Total Weight
Cost
Cost= Total Weight X 2.50
Begin
End
Design the Algorithm
Flow Chart
-
8/3/2019 Bab 1 - Introductory Concepts
24/25
#include
main ()
{
int weight, payment;
scanf ("%d", &weight);
payment = weight * 2;
printf ("The payment: RM%d.00", payment);
getch();
return 0;}
-
8/3/2019 Bab 1 - Introductory Concepts
25/25
Test using various data