Sie sind auf Seite 1von 33

Continuation of Lesson 1

Compilers and Interpreters


 Compilers – is needed to translate a program
written in a compiled language into machine
understandable code before you can run the
program on your machine.
 Interpreter – is needed to translate the high-level
instructions into machine understandable
instructions at runtime. A program written in an
interpreted language can be run immediately after
you finish writing it, or while you are writing it.
Four Step Process in
writing & testing the program:
 1. writing and editing the program
 2. compiling the program

 3. linking the program with the required


library modules, and
 4. executing the program.
Four Step Process in
writing & testing the program:
 1. writing and editing the program –
is the process of creating and modifying
C source code – the name given to the
program instructions you write.

IDE – integrated development


environment, an editor often provides
a complete environment for writing,
managing, developing and testing your
programs.
Four Step Process in
writing & testing the program:
 2. Compiling the program – this is the
process of converting your source code into
machine language and detects and reports
errors in the compilations process with the
use of a compiler. The compiler can detect
a wide range of errors that are due to
invalid or unrecognized program code, as
well as structural errors.
input – source code – source file
output – object code – object files
Four Step Process in
writing & testing the program:
 3. linking the program with the
required library modules – the linker
combines the various modules from
program libraries supplied as part of C, and
welds everything into an executable whole.
The linker can also detect and report errors.
If the program is of any significant
size, it will consist of several separate
source code files, which can then be linked.
Four Step Process in
writing & testing the program:
 4. Executing the program – this is the
stage where you run your program. This
stage can also generate a wide variety of
error conditions that can include
producing the wrong output. If this
happens, it’s back to the editing process to
check your source code.
Stages of Program Development
 1. Defining & Understanding the problem
 2. Planning/Develop the Solution

 3. Implementation/Coding the Program

 4. Testing/Running/Checking the program


 2 Types of Testing

 Blackbox Testing
 Whitebox Testing
 5. Program Documentation
 6. Maintenance
Stages of Program Development
 1. Defining & Understanding the problem
– At this stage we list the information related
to the problem and the requirements from
the computer. It consist of identifying what
kind of input to expect, how the input is to
be processed and what kind of output is
required.
Stages of Program Development
 2. Planning/Develop the Solution– in developing
the solution we will need detailed plans. We will
need to specify what the program does by dividing it
into a set of well-defined and manageable chunks.
We will also need to detail the way in which these
chunks connect and what information each chunk
will need when it executes.
 Tools in program logic formulation/Ways of
planning the solution
 structure charts – used to designed the whole program
 algorithm/pseudocode used to design the individual
parts of the program
 flowcharts
Stages of Program Development
 3. Implementation/Coding the Program –
After planning the solution, our next step is
to start writing the program codes. Coding is
the act of actual writing the computer
program. This stage requires an extensive
knowledge in the programming language to
be used.
Stages of Program Development
 4. Testing/Running/Checking the program –
At this stage the programs are tested by running it
and observing the output it produce and the
programmer makes sure that the program
performs the way it is intended.
 Debugging – is the process of finding and correcting
errors in the program, it means to detect, locate and
correct logical or syntax errors.
 2 Types of Testing
 Blackbox Testing– system test engineer & user
 Whitebox Testing - programmer
Stages of Program Development
 Two Types of Testing
 1. Blackbox Testing – gets its name from the
concept of testing the program without
knowing what is inside it, without knowing
how it works. The test engineer uses
requirements and his knowledge systems
development and the user working
environment to create a test plan that will
be used to test the system as a whole.
Stages of Program Development
 Two Types of Testing
 2. Whitebox Testing – assumes that the
tester knows everything about the
program. The programmer knows exactly
what is going on inside the program. The
programmer makes sure that every
instruction and every possible situation has
been tested.
Stages of Program Development
 5. Program Documentation – usually
includes the necessary information about the
requirements of the program – the operating
system and hardware requirements needed for
the program to run. Typical program
documentation includes the origin of the
problem, brief narrative description of the
program, logic tools, etc. It also contains
technical information such as who created the
program and who to contact, and instructions
on the use and maintenance of the program.
Stages of Program Development
 6. Maintenance – is the final stage in
programming or updating the program. This
is where the programmer is tasked to keep
the program running smoothly and updated
with the development and changes in the
field where it is used.
Program Logic Formulation
 It provides the tools needed to design the
right solution by helping you define and
identify the problem, its requirements and
the needed instructions.
 Tools in program logic formulation

 algorithm
 pseudocode
 flowcharts
 structure charts
Tools in program logic formulation
 Algorithm – is a list of steps(similar to a
recipe) for solving a problem. Designing an
algorithm to solve a problem requires you to
write a step-by-step procedures and then
verify that it solves the problem as intended.
 a typical algorithmic steps in solving a problem:
1. Read the data
2. Perform computations
3. Display the results
Problem:
The price of apples per kilo is 50 pesos. If
the customer buys 3 or more kilos of apples,
5 pesos will be discounted for every kilo.
Determine the total cost of apples
purchased.
Algorithm:
1. Enter the number of Apples.
2. Compute the total cost of apples in pesos
3. Display the Total Cost of Apples in pesos.
The following are algorithmic refinements:
1. Enter the number of Apples.
1.1 Input quantity of apples purchased in kilos
2. Compute the total cost of apples in pesos
2.1 If quantity of apples is equal or more than 3
kilos.
2.2 Compute cost of apples with discount
Else
2.3 Compute cost of apples without discount
3. Display the Total Cost of Apples in pesos.
Tools in program logic formulation
 Pseudocode –It is an English like
nonstandard language that lets you state your
solution with more precision than in plain
English. Algorithm refinements are also
expressed in pseudocode.
Pseudocode uses indentation and
often use the statements, if then and else to
show the logical structure of the algorithmic
steps.
Refined algorithmic steps expressed in Pseudocode:
1. Enter the number of Apples.
1.1 Input quantity of apples purchased in kilos
2. Compute the total cost of apples in pesos
2.1 If quantity of apples in kilos >= 3 kilos
2.2 Compute cost of apples with discount
2.2.1 Compute for the Total Discounts
Total Discounts=Qty. of Apples in Kilos *Discount
Cost of Apples=(Qty. of Apples in Kilos*Amount of
Apples per kilo) – Total Discounts
Else
2.3 Compute cost of apples without discount
Cost of Apples=Qty. of Apples in Kilos*Amount of Apples
per kilo
3. Display the Total Cost of Apples in pesos.
Tools in program logic formulation
 Flowchart – is a diagrammatic or graphical
representation that illustrates the sequence of
operations to be performed to get the solution
of a problem.
 Variable – memory cells used for storing a
program’s input data and its computational
results are called variables. It is the
representation of the idea that is changing.
 Constant – named item used to specify a
name for a memory cell that will contain a
value that does not change. (fixed value)
Types of Flowchart
 Program Flowchart – describes graphically in
detail the logical operations and steps within a
program and the sequence in which these steps
are to be executed for the transformation of
data to produce the needed output.
 System Flowchart – portray the interaction
among data, hardware, and personnel. It
illustrates more on the components of the
system.
Flowcharting Symbols
Input/Output Symbol
(Parallelogram) represents an
instruction to an input or output device.

Processing Symbol (Rectangle)


computational steps or processing
function of a program

Decision Symbol (Diamond) decision


making and branching
Flowcharting Symbols
Preparation/Initialization Symbol
(Hexagon) is used to assigned or
initialized a value to a variable.

Terminal Symbol (Oval) used to


designate the start and the end of a
program.

On-page connector (Small Circle)


used to connect one part of a flowchart
to another without drawing flow lines.
Flowcharting Symbols
Off-page Connector (Small
Pentagon) used instead of the on-page
connector to designate entry to or exit
from a page when a flow chart requires
more than one page.

Flow Direction Indicators


(Arrowheads) used to show the
direction of processing or data flow.
These are added to flow lines.

Flow Line (Horizontal/Vertical lines)


used to show reading order or sequence
in which flowchart symbols are to be
read.
Guidelines for preparing a flowchart:
 A flowchart always begin with START and is
completed by END symbol;
 Symbols are interconnected using arrows;
 Use comma (,) to separate data, and semi
colon (;) to separate instructions;
 The arrow’s head indicates the direction to be
followed; The usual direction is from left to
right or top to bottom.
 All the symbols except the diamond may have
only one arrow branching out, but may have
one or more arrows branching in;
Guidelines for preparing a flowchart:
 If the flowchart becomes complex, it is better to use
connector symbols to reduce the number of flow
lines.
 The sequence of procedure using symbols matters
because it indicates the logical steps to be followed;
 A flowchart may contain many symbols of the same
kind depending on the solution of the problem;
 There may be many types of flowcharts to solve one
problem but the simplest flowchart is advisable and
most efficient. It should be clear, neat and easy to
follow.
Flowchart Development
 Flowcharts are designed using the most basic
methods of control namely:
 sequential
 selection
 repetition
 modular
Flowchart Development
 Sequential – steps are performed in strictly
sequential manner, each step being executed
once. This is the simplest method of control. It
is easy to develop and understand.
 Selection – the execution of instructions by
selection, wherein conditions for a series of
alternative statements are evaluated to specify
which instruction is to be executed.
Flowchart Development
 Repetition – It consists of repeating a
program, or a selection of programs, and
substituting new data for each repetition. A
loop is used when it is desired to make the
same calculation on more than one set of data.
Program loops play an important part in data
processing since they provide efficient means
of processing various sets of data with the same
program segment.
Modular Structure
 Modules – a module is a group of statements
that exist within a program for the purpose of
performing a specific task. Modules are
commonly called procedures, subroutines,
subprograms, methods, and functions.
 Structure chart/hierarchy chart – shows the
functional flow through the different modules in
a program.

Das könnte Ihnen auch gefallen