By: Madam Noraini Binti Desa Jke, Polisas 2014: DEC 2012 Fundamental Programming

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 36

DEC 2012

Fundamental
Programming
CHAPTER 1:
INTRODUCTORY TO PROGRAMMING

By : Madam Noraini Binti Desa


JKE, POLISAS 2014
1

1.1: Know The Programming Language

How human and computer


interact :

1.1: Know The Programming Language

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.

1.1: Know The Programming Language


C Programming
C is designed in 1972 by Dennis Ritchie as a tool to develop UNIX operating system,
one of the operating system today.
Two advantages of C are:
a) Transportable language. User can write C in a computer then it is compiled to
allowed it to run in
another computer.
b) It has both features in high-level and low-level language at the same time.
In low-level, C allows user to access memory location and also influence data allocation
in CPU register.
C also supports Boolean operation such as shift that can be used in arithmetic
operation and graphic operation.
In high-level, C allows memory management. It also allows higher to lower level
translation.
C also allows structure-coding, supports numeric types and provides set of instructions.
Cs implementation is provided with large library function from the function in UNIX.
The Library provides memory, file management and etc.

1.1: Know The Programming Language


Structured of program code in C:

1.1: Know The Programming Language

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

1.1: Know The Programming Language


Sample of C Program
Example 2
The pseudo code below is to find the volume of a box if the length, width and height are
given. Write the program based on the pseudo code below.

1.2: Know The Definition of Programming

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.

1.2: Know The Types of Programming


Various Types of Programming Languages
a. Machine languages
b. Assembly languages
c. High Level languages

1.2: Know The Types of Programming

Machine Language

The lowest level of language.


Uses 1s and Os / binary digits to represents data and instructions
Examples: 0 represents off and 1 represents on.
The only language that the computer could understand (does not require translator).

10

1.2: Know The Types of Programming

Assembly Language

Known as symbolic language.


It uses mnemonic codes - a symbol chosen to help user to remember
replace 0 and 1
For example, A represented ADD and S represented SUM
Computer does not understand the language so it needs an assembler to translate
the program to machine language.

11

1.2: Know The Types of Programming

High Level Language

Instruction is written as a series of English-like words.


Translator (Compiler/Interpreter) is needed to translate high level language
to machine language.
It is Machine-Independent. The program can be written and executed on
any computer.
Example: FORTRAN, Pascal, BASIC, C, C++, Java, etc.

12

1.2: Know The Types of Programming


Some Well-known Programming Languages:

13

1.2: Know The Types of Programming

Types of Programming and Structure Programming


Methodology
Structured Programming
Modular Programming
Object-Oriented Programming

14

1.2: Know The Types of Programming

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

Receive user text input

Process user input

Return results to user

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

1.2: Know The Types of Programming

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.

Modular Programming - Process

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

An example of code that Doesnt


Use Modular Programming

A simple Example of Modular


Programming

1.2: Know The Types of Programming

Object Oriented Programming

Is about relation between the data and the code


operating on the data (or data operating on the code)
Is a programming paradigm(contoh/model) that uses
object-data structures consisting of data fields and
method together with their interactions to design
applications and computer programs.
Programs techniques may include features such as
data abstraction(jenis-jenis/ringkasan),
encapsulation(rumusan), modularity,
polymorphism(boleh mewakili bk jenis bentuk/data),
and inheritance(warisan). Many modern programming
languages now support OOP.

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.

Object oriented program


Load program

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

Comparison between the following


types of programming
a) Structured programming
) The main advantage for structured
programming is that it make input easy
and also it is better to use because it does
not merges the data we stored in strings
and variables, sometime it happens that
we get merged data if we dont use
structured data. And it also make easy to
manage variables.

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

Modular Programming Need and


Approach
Typical industry programming projects
consist of thousands of lines of code or more
Analogous approaches: manufacturing a
spacecraft, or a car Manufacture Individual
components, test separately
Assemble into larger components, integrate
and test

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

Why Object Oriented


Language
Reusability-Fasten the project
Easily adjusted
Flexible
Easy maintenance
Reduce the risk for complex projects

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

You might also like