PF - Lab 2 - 2018
PF - Lab 2 - 2018
Programming LAB 02
PRE-PROGRAMMING PHASE
Fundamentals
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES
What Problem Can Be Solved By Computer
• When the solution can be produced by a set of step-by-step procedures or actions.
• This step-by-step action is called an algorithm.
• The algorithm will process some inputs and produced output.
• Solving problem by computer undergo two phases:
– Phase 1:
• Organizing the problem or pre-programming phase.
– Phase 2:
• Programming phase.
PRE-PROGRAMMING PHASE
This phase requires five steps:
Example # 01:
Write a Problem Analysis Chart (PAC) to find an area of a circle where
area = pi * radius * radius
The interaction will form a hierarchy, called Hierarchy Input Process Output Chart
(HIPO) or Interactivity Chart (IC). Programming which use this approach (problem is
divided into subtasks) is called Structured Programming.
Example # 02:
Write a Hierarchy Input Process Output (HIPO) to find an area of a circle where
area = pi * radius * radius
III. Developing the Input Process Output (IPO) Chart
– Extends and organizes the information in the Problem Analysis Chart.
– It shows in more detail what data items are inputs, what is the processing or
modules on that data, and what will be the result or output.
– It combines information from PAC and HIPO Chart.
Example # 03:
Write a Input Process Output (IPO) to find an area of a circle where
area = pi * radius * radius
Flowchart
Functions
Functions have been divided into classes.
1. Mathematical functions.
Often used in science and business, mathematical functions calculate such things as square root,
absolute value, or a random number. Other mathematical functions used primarily for scientific
purposes have not been included in the table.
2. String functions.
These are used to manipulate string variables. For example, they copy part of the string into another
variable, find the length or the number of characters in the string, and so forth.
3. Conversion Function.
These functions are used to convert data from one data type to another. For example, since character
strings cannot be used in calculations, one of these functions would convert a string value to a
numeric value.
4. Statistical functions.
These functions are used to calculate things such as maximum values, minimum values, and so forth.
5. Utility Function.
This class is very important in business programming because most reports require some use of utility
functions. They access information outside the program and the language in the computer system.
Examples of these include date and time functions.
Operators and Their Computer Symbols
Mathematical Operators:
Relational Operators:
Logical Operators:
Hierarchy of Operations
Example:
Assume the programmer has written the following equation:
F = NOT(A < B) AND (C OR D)
The operations are completed in hierarchical order from left to right, as illustrated in the
Developing a Table of All Possible Resultants of a Logical Expression
Example:
Two unknowns—A and B.
Four combinations: B can be either True or False for each value of A..
Decision: