PLF (Chapter1)
PLF (Chapter1)
Hardware and Software are the two major components of any computer
system. Hardware is the equipment, or the devices, associated with a computer.
For a computer to be useful, however, it needs more than equipment; a
computer needs to be given instructions. The instructions that tell the computer
what to do are called software, or programs, and are written by programmers.
NOTE: Although there are differences in how compilers and interpreters work, their basic
function is the same – to translate your programming statements into code the computer can
use. When you use a compiler, an entire program is translated before it can execute; when
you use interpreter, each instruction just prior to execution.
1
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
Stir
Add two eggs
Add a gallon of gasoline – Don’t do it!
Bake at 350 degrees fro 45 minutes
Add three cups of flour
NOTE: Programmers call some code errors semantic errors. For example, if you misspell a
programming language word, you commit a syntax error, but if you use an otherwise
correct word that does not make any sense in the current context, you commit semantic
errors.
Once instructions have been inputted to the computer and translated into
machine language, a program can be run, or executed.
Computer storage comes in two broad categories. All computers have internal
storage, often referred to as memory, main memory, primary memory, or
random access memory (RAM).
NOTE: Even though hard disk drive is located inside your computer, the hard disk is not
main, internal memory. Internal memory is temporary and volatile; a hard drive is
permanent, nonvolatile storage.
The programmer’s job can be broken down into six programming steps:
1. Understanding the problem
2. Planning the logic
3. Coding the program
4. Using software to translate the program into machine language
5. Testing the program
6. Putting the program into production
2
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
If there are no
Write and correct Compile the syntax errors Compile the
the program code program program
If there are
syntax errors
List of Program
syntax output
error
messages
When data items are stored for use on computer systems, they are often stored
in what is known as a data hierarchy, which describes the relationships between
data components.
In the data hierarchy, the smallest usable unit of data is the character.
Characters are letters, numbers, and special symbols. It also includes space and
tab. Characters are made up of smaller elements called bits.
3
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
Characters are grouped together form a field. Field is a single data item, such as
lastName, streetAddress.
Related fields are often grouped together to form a record. Records are groups
of fields that go together for some logical reason. E.g. individual student record
Related records, in turn, are grouped together to form a file. File are groups of
records that go together for some logical reason. E.g. Student File
Finally, many organizations use database software to organize many files. A
database holds groups of files, often called tables that together serve the
information needs of an organization.
Database
File
Record
Field
Character
A database contains many files. A file contains many records. Each record in a
file has the same fields. Each record’s fields contain different data items that
consist of one or more stored characters in each field.
Whether the data has been stored in a flat file or database, when a program
needs all the fields in a record, you can write programming statements to get or
input each field in one of several ways.
Get name
Get address
Get salary
Most languages also allow you write a single statement in the following format:
4
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
Flowcharts are the most widely used general method for describing infromation
and data processing systems.
Definition of Terms:
INPUT
PROCESSING
(Phase 1) (Phase 2) OUTPUT
(Phase 3)
Phase 1: Input → Recording or Capturing
Phase 2: Processing → Classification and sorting, Storage and Retrieval,
Summarization, Analysis, Communication (reporting),
Calculation
Phase 3: Output → Displaying of Results, Printing Results
5
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
FLOWCHARTING SYMBOLS
The American National Standard Institute (ANSI) has adopted a standard set of
symbols to be used in flowcharting. The most commonly used symbols are
presented below.
6
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
A A
A A
ADVANTAGES OF FLOWCHART
In programming, storing of data is very important and this becomes possible with
the use of variables and constants.
7
RLD
UNIVERSITY OF MAKATI – COLLEGE OF COMPUTER SCIENCE
PROGRAM LOGIC FORMULATION using C++
The variable names used in our discussion follow only three rules:
1. Variable names must be one word. The name can contain letter, digits,
hyphens, underscores, or any other characters you choose, with the
exception of spaces.
2. Variable names should have some appropriate meaning.
3. Variable names may not begin with a digit, although usually they may
contain digits.
Camel casing – is the format for naming variables in which the initial letter is
lowercase, multiple-word variable names are run together, and each new word
within the variable name begins with an uppercase letter.
-End of Chapter 1-
8
RLD