Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Introduction to Programming

The document provides an introduction to programming, defining key terms such as programs, programming, and programming languages. It outlines the steps in programming, including defining the program's scope, creating algorithms, and using flowcharting as a method for visual representation of processes. Additionally, it discusses the advantages and limitations of flowcharts, as well as common flowchart symbols used in programming.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction to Programming

The document provides an introduction to programming, defining key terms such as programs, programming, and programming languages. It outlines the steps in programming, including defining the program's scope, creating algorithms, and using flowcharting as a method for visual representation of processes. Additionally, it discusses the advantages and limitations of flowcharts, as well as common flowchart symbols used in programming.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Introduction to

Programming
Definition of Terms
Program – a plan of action for achieving
something / education system to develop
or provide something.

Programming – creating of computer


programs / designing or writing of computer
programs.

Programming Languages– an English


like language used to construct computer
programs.
Computer program
 set of instructions for a computer
to do.
 some examples are Basic, C, C++,
Java, Turbo Pascal, V13.
 They express the same concept in
different ways according to the
syntax which is unique to each one.
(Syntax – rule-based arrangement /ordering.)
Why Programming Languages are
develop?

1.) Before computers are “hardwired”


(could perform one task) and so now,
you could tell a computer what to do
without having to take it apart.

2.) Computer has a simple machine


language - binary code.
Compiler  a computer program that
translates a program written in one of the
P.L. into a form that the computer can
understand and execute.

 the output of this translation is an EXE


file (executable)
 each P.L. has its own compiler.
Steps in Programming:
1. Define the scope of the program (what it
will do exactly). This is called program
specification.

2. Plan the sequence of computer


operations.
(pseudo-coding: writing the instructions in
somewhat broken English words or
flowcharting: making a diagram showing
the order of computer actions and data
flow – in other words, develop what you
call an ALGORITHM).
Steps in Programming:
 Algorithm – problem-solving procedure /
logical step by step procedure

 Pseudo-coding – writing a code for a


program using no specific P. Language
but some combination of English and
Mathematical operations.

 Flowcharting – diagram showing


sequence of actions.
Steps in Programming:

3.) Translate your algorithm into your


preferred programming language
(otherwise known as ENCODING).

4.) TEST the program (run to see if it


works).

5.) DEBUG the program (fix the errors).


Constructing an Algorithm
Algorithm
 is a set of instructions to solve
a problem.
 no rule in making a perfect algorithm
but have some guidelines.
 It has to have a definite start and end.
 It has to end in either success or
failure after a finite number of steps.
Constructing an Algorithm

 Thesequence has to be clear.


You can do as simple as possible.

 The input and output have to be


well-defined. Know what
information is needed to solve the
problem and what output or result
must be produced.
Constructing an Algorithm

 Ithas to be effective. Meaning


has the capability to solve the
problem.

 The scope of the input has to be


clear.
Two methods of Algorithm
1. Pseudo – coding
2. Flowcharting

Pseudo – coding is writing a code


for a program using no specific
programming language but some
combination of English and
Mathematical operations.
Flowcharting
 Diagram showing sequence of actions.
 A diagram representing the logical
sequence in which a combination of steps
or operations is to be performed.
 Consists of labeled geometrical
symbols that are interconnected to
provide a pictorial representation of a
data processing procedure.
 A visual representation of an algorithm.
In program development, the programmer
uses flowcharting to:

 Marshall and organize facts on paper


 Outline problems, logic and solution
 Deal systematically with the problem as
a whole
 Build step-by-step, the reference
documentation and reminders.
Advantages of Flowchart

• Since Flowchart is language-independent,


they can be learned and applied without
formal knowledge of a programming
language.

• It enforces users to give attention to


significant matter over the less significant
ones.
Advantages of Flowchart

 Being graphically portrayed, Flowchart


provides an alternative to the usual
narrative description of a system or a
program.

 Flowcharts are easier to understand


than a program written in a particular
programming language.
Limitations of Flowchart:
• Flowcharts do not represent a
programming language and are more of a
person-to-person than a person-to-
computer means of communication. A
computer cannot accept a program
described in Flowcharting form.

 Since thinking in graphic terms is not


normal, Flowcharts cannot be viewed as a
natural means of communication.
Limitations of Flowchart:
• Certain details often require a long
sequence of interconnected symbols
which could easily be described in just a
few lines of explanation.
 It does not convey why a given set of
operations is made. Flowcharts only
portray how.
 Flowcharts do not highlight the important
details since each step receives as much
attention in a flowchart as any other.
Flowchart Symbols
Input/Output Symbol (Parallelogram)
Represents an instruction to an input or
an output device.

Processing Symbol (Rectangle)


Represent a group of program instructions
that perform a processing function of the
program such as to perform arithmetic
operations, or to compare, sort, etc.
Flowchart Symbols

Decision Symbol (Diamond)


Denotes a point in the program where
more than one path can be taken. Used to
document points in the program where,
based upon variable conditions, a branch
to alternative paths is possible.
The particular path that is chosen depends
on the answer to a question or the result of
a test which is inserted in the Symbol.
Flowchart Symbols

Preparation Symbol (Hexagon)

 Used to represent an instruction or


group of instructions that will alter or
modify a program’s course of
execution. Used to specify operations
such as control, index register,
initialization, switch setting, and
indicating loops.
Flowchart Symbols

Terminal Symbol (Oval)

 Used to designate the beginning and


the end of a program, or a point of
interruption. Used elsewhere for
specifying error conditions such as
parity error checks or detection of
invalid characters.
Flowchart Symbols

On-page connector (Small Circle)


 This is a non processing symbol
which is used to connect one part of
a flowchart to another w/o drawing
flow lines. It denotes an entry or an
exit from another part of the
flowchart and also used to change
the reading sequence of a flowchart
on the same page.
Flowchart Symbols

Flow Direction Indicators (Arrowheads)


 Used to show the direction of processing
or data flow. These are added to flow lines if
a flowchart appears confusing in its layout.

Flow Lines (Horizontal / Vertical Lines)


 Used to show reading order or sequence
in w/h flowchart symbols are to be read.
Sometimes drawn w/ arrowheads.
Notation Used in Flowcharting

Notation – used in naming data within flowcharting operations.


Notation Meaning
+ Addtition
- Subtraction
* Multiplication
/ Division
& Logical And
() Grouping
| Logical Or
= Equal to
> Greater than
< Less than
<> or ≠ Not Equal to
> Greater than or Equal to
< Less than or Equal to
Y Yes
N No
Activity 1F:
1. Given three (3) numbers A,B,C. Draw a
flowchart to compute and give the output of
the sum, average and product of these
values.
2. Given two (2) numbers X & Y. Draw a
flowchart to determine the difference
between X & Y. If X –Y is negative, compute
N= X + Y; if X-Y is zero, compute N=2X +
2Y; and if X-Y is positive, compute N= X*Y.
Print out the values of X,Y, and N.
3. Given two (2) numbers X&Y. Draw a
flowchart to print out the values of X&Y. If
the value is greater than zero, get the
difference of X&Y, otherwise compute the
sum and print out the difference and
sum.
4. The radius of a circle is equal to one unit.
Draw a flowchart to compute the
corresponding area of the circle and print
out the value of the radius and the area.
A=Пr2; П=3.1416
5. The ABC Manufacturing Company plans to
give a year-end bonus to each of its
employees. Draw a flowchart which will
compute the bonus of an employee.
Consider the following criteria:
If the employee’s monthly salary is less
than 10thousand pesos, the bonus is 50%
of the salary; for employees with salaries
greater than 10thousand pesos, the bonus
is 10thousand pesos. Print out the name
and the corresponding bonus of the
employee.

You might also like