0% found this document useful (0 votes)
105 views25 pages

Bab 1 - Introductory Concepts

The document discusses various topics related to programming including defining key terms like programs, programmers, and programming languages. It also covers different types of programming languages and paradigms as well as the stages of the problem solving process from problem analysis to testing. The document provides examples of different programming languages and describes the basic elements involved in analyzing and solving problems using programming.

Uploaded by

Nur Hasanah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views25 pages

Bab 1 - Introductory Concepts

The document discusses various topics related to programming including defining key terms like programs, programmers, and programming languages. It also covers different types of programming languages and paradigms as well as the stages of the problem solving process from problem analysis to testing. The document provides examples of different programming languages and describes the basic elements involved in analyzing and solving problems using programming.

Uploaded by

Nur Hasanah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Course Lecturer: Pn Norhayati bt Jais Correction and rewrite: Norzaiwin B Zainal Abidin

Define programme, programmer and programming language Types of programming language Types of programming:
Structured programming Modular programming Object-oriented programming

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

Programme - A set of instructions that tells the computer what to do Programmer A person who is involved in the programming phases. Programming language is the language understood by the computer, used to tell the computer what to do.

Machine languages
is a true computer language machine specific instructions, consists of binary numbers i.e 0 and 1. lowest level representation of computer program

Assembly languages
Using mnemonics to represent machine language instructions (translated via assemblers) Example: mov ax, 1234h (mov value 1234h into register ax)

HighHigh-level languages
Codes similar to everyday English Use mathematical notations (translated via compilers) Example: grossPay = basePay + overTimePay

Structured Programming
Computer programming in which the statements are organized in a specific manner to minimize error or misinterpretation. Ada. ALGOL, Pascal, C, PL/I and Ada.

Functional / Modular Programming


Modular programming is subdividing program into separate subprograms such as functions and subroutines. make program shorter, hence easier to read and understand. Scheme, LISP

Object Oriented Programming (OOP)


A computer programming methodology that focuses on data rather than processes, with programs composed of self-sufficient modules (objects) containing all the information needed to manipulate a data structure. Abbreviated OOP. Java, C++

Problem requirements Problem Analysis Program Design (Algorithm) Writing Programme Testing and debugging Documentation

1. Problem Requirements
Before any problem can solve, we really have to understand what is to be solve. To understand, we should think and ask question

2. Problem Analysis
All computer programs have several elements in common.
Input Process Output

They receive data input from users, store the data on some storage device (e.g. hard disk), process the data into useful information, and finally produce output in the form of reports. (Figure 1)

I N P U T

P R O C E S S

O U T P U T

STORAGE

2. Problem Analysis
Identify and understand the problem to be solved. Problem analysis is done by determining 3 main things:
Input needed Output has to be produced Process to be carried out in order to get the output based on the input

INPUT INPUT

PROCESS PROCESS (programme) (programme)

OUTPUT OUTPUT

Better known as Algorithm Algorithm is a list of sequential steps to solve a problem 2 methods in writing algorithm :
Pseudo Code steps in problem solving (logic) written using a combination of spoken language and some programming language semiformal. Flow Chart steps in problem solving (logic) using diagrams and specific symbols.

* PSEUDO CODE
Pseudo Code steps in problem solving (logic) written using a combination of spoken language and some programming language semiformal. Example :

Begin Read a Read b Count y=a*b Write y End

* Flow Chart Symbols


BEGIN / END PROCESS

INPUT / OUTPUT

DECISION

CONTINUE

ACTIVITY FLOW

Implementation phase, where the code is written and typed using the computer A logic problem solving represented by pseudo codes dan flow chart converted to computer programme, using suitable language Language example: C, C++, Visual Basic, Java, PHP

Program that have been complete, has to be teated/run to make sure the output is correct. Debugging that is by inserting true data to be tested If there is an error, correct it, depend on which error.

There tree types of error. Logical Error due to ways of solving and steps 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.

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

Define & Analyst Problem o Define & knowing problems o Define data problems input & output

Prepare documentation o Problem analysis document and program and modules involve
Correct Program Error

Program Design o Plan & fixed strategy o Knows data model, component & relation o Build algorithm/ flowchart

Code the program Translate the algorithm into program code using the specific programming language

Test Program o Test the program using computer for errors. o Correct output as define by user.

THE PROBLEM
A durian seller like to calculate the cost of the durian the customer have to pay. If the durian cost RM2.50 per kilogram. Program a way for calculating the total cost of durians for an amount in kilogram of durians sell.

Defination & Analising 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

problem: Analising the problem Define the input, output and the proces.
Total Weight (Kg) Cost = Total weigrt x RM2.50 Cost

Design the Algorithm


Pseudo code: Begin: Input:

read the total weight


Proses:

calculate cost : cost = total weight x 2.50


Output:

display cost
End.

Design the Algorithm Flow Chart


Begin

Total Weight

Cost=

Total Weight X 2.50

Cost

End

#include <stdio.h> main () { int weight, payment; scanf ("%d", &weight); payment = weight * 2; printf ("The payment: RM%d.00", payment); getch(); return 0; }

Test using various data

You might also like