By: Madam Noraini Binti Desa Jke, Polisas 2014: DEC 2012 Fundamental Programming
By: Madam Noraini Binti Desa Jke, Polisas 2014: DEC 2012 Fundamental Programming
By: Madam Noraini Binti Desa Jke, Polisas 2014: DEC 2012 Fundamental Programming
Fundamental
Programming
CHAPTER 1:
INTRODUCTORY TO PROGRAMMING
Programming Language
Definition:
A set of rules and reserved words (keywords)
that can be used to tell a computer what are
the operations to be done.
Artificial language composed by a fixed
vocabulary and set of rules is used to create
instructions for the computer to follow.
Sample of C Program
Example 1
Write a program that can accept a three integer data entered by the user.Get the
average number and finally show the numbers and average numbers
Definition Of :
Program:
A set of step-by-step instructions that directs a
computer to perform a specific task and to
produce the required results.
Programming:
Programming is a process of designing/ creating
a program.
Programmer:
Programmer is a person who writes the program.
Machine Language
10
Assembly Language
11
12
13
14
a) Structured Programming
Definitions of Structured Programming
Structured programming can be defined as a
Software application programming techniques
that follows a top design approach with block
oriented structures.
It support loop such as while, do-while and for.
Structured Program
The most popular structured programming
languages include C, C++, Ada and Pascal
Cont
Codes similar to everyday English
Use mathematical notations
Example;
if ( x < 10)
{
printf(Too low, try again\n);
scanf(%d, &x);
}
Structured Program
Ask user to text input
Structured programming is as
follows
Program Start
var
var
var
function {.}
function {.}
function {.}
main{}Program End
You have units of code, which operate on variables, and
are called in reference to those variables, to follow a
structure acting on those variables
b) Modular Programming
Programming paradigm based on data types.
An object scores a data type value; variable name
refers to object.
A programming style that brakes down program
functions into modules, each of which accomplishes
one function and contains all the source code and
variables needed to accomplish that function.
Modular programming is a solution to the problem of
very large programs that are difficult to debug and
maintain. By segmenting the program into modules
that perform clearly defined functions, you can
determine the source of program errors more easily.
Requirement
s
conceiv
e
Module
1
spec
design
Module
1
design
build
Module
Code 1
Module
2
spec
design
Module
1
design
build
Module
Code 2
design
Module
1
design
build
Module
Code 3
Module
3
spec
C
I
D
O
Integrat
e & Test
Final
Cod
e
Cont
Is one the newest and most powerful paradigms. In
object oriented programs, the designer specifies
both the data structures and the types of operations
that can be applied to those data structures.
This pairing of a piece of data with the operations
that can be performed on it is known as an object. A
program thus becomes a collection of cooperating
objects, rather than a list of instructions.
Objects can store state information and interact with
other objects, but generally each object has a distinct
limited role.
Button
Text input
Draw window
Window
Program ready to
use
Cont..
An object stores a data type value; variable name refers
to object.
Object-oriented Programming (OOP) is a programming
paradigm based on data types.
Variables can be objects, which have their own data and
functions.
Think like C and structures, except structures can have
functions in them which operate specifically on their
own data
c) Object oriented
Cont
The most popular object-oriented
programming languages include
Java, Visual Basic , C#, C++ and
Phyton.
Object oriented programming
languages such as SmallTalk and
HyperTalk,
incorporate(mengandungi) modular
programming principles
b) Modular programming
A detailed process of problem solving
-Break a large problem into several
smaller
Sub-sections are solved separately
by observing that all these small
modules to solve the whole problem
of the origin
Advantages of Modular
Programming
Manageable: Reduce problem to smaller; simpler
humanly comprehensible problems
Divisible: Modules can be assigned to different
teams/programmers
Enables parallel work, reducing program development
time
Facilitates programming, debugging, testing,
maintenance
Portable: Individual modules can be modified to run
on other platforms
Re-usable: Modules ca be re-used within a program
and across programs
c) Object Oriented
Fourth-generation language is object oriented
Programmers will more tend to think of the
objects involved
The problems and the relationship between
objects
Examples of programming languages are C+
+, Java
TYPES OF PROGRAMMING
STRUCTURED
PROGRAMMING
A disciplined
approach
to writing programs
that are clear,
demonstrately
correct and easy to
modify.
OBJECT-ORIENTED
PROGRAMMING
MODULAR PROGRAMMING
software design
technique that
increases the extent
to which software is
composed of
separate,
interchangeable
components.
programming
paradigm that
uses "objects"
data structures
consisting of data
fields and
methods together
with their
interactions to
design
applications and
computer
programs.
Thank You!!
36