Programming 1
Section: BS in Information Technology - 1A
Day: SAT
Time: 11:00-2:00
Instructor: Percival A. Fernandez, MSIT
REVIEW OF THE PREVIOUS TOPIC
WHAT IS A COMPUTER?
WHAT ARE THE COMPONENTS OF A
COMPUTER?
WHAT IS A PROGRAM?
WHAT IS PROGRAMMING?
WHAT IS A PROGRAMMING LANGUAGE?
WHAT IS AN ALGORITHM?
• An algorithm is any set of detailed instructions which results in a
predictable end-state from a known beginning.
• Algorithms are only as good as the instructions given, however, and
the result will be incorrect if the algorithm is not properly defined.
• An algorithm is a list of rules to follow in order to solve a problem.
• Algorithms need to have their steps in the right order.
WHAT IS AN ALGORITHM?
• Find the sum two numbers N and M
The procedure is:
1. Enter the two numbers in the variables N and M.
2. Sum them and save the result in the variable sum.
3. Output the result.
WHAT IS AN ALGORITHM?
• Calculate the Interest of a Bank Deposit
Algorithm:
Step 1: Read amount,
Step 2: Read years,
Step 3: Read rate,
Step 4: Calculate the interest with the formula
"Interest=Amount*Years*Rate/100
Step 5: Print interest,
WHAT IS A FLOWCHART?
• A flowchart is the graphical or pictorial representation of an algorithm with
the help of different symbols, shapes, and arrows to demonstrate a process or
a program. With algorithms, we can easily understand a program.
• The main purpose of using a flowchart is to analyze different methods.
• Flowcharts can be used for presenting algorithms.
RULES OF DRAWING FLOWCHARTS FOR
ALGORITHMS
There are some basic shapes and boxes included in flowcharts that are
used in the structure of explaining the steps of algorithms. Knowing how
to use them while drawing flowcharts is crucial. Here are some rules that
should be known:
All boxes of flowcharts are connected with arrows to show the logical
connection between them,
Flowcharts will flow from top to bottom,
All flowcharts start with a Start Box and end with a Terminal Box.
TYPES OF FLOW CHART
There are two types of flow charts, given here with its short description:
System Flow Charts - These flowcharts describe the logical flow of the
process, actually the sequence of events in business that happens before
something is achieved
Program Flow Charts - This is a flowchart of a single program in high
level language. This type of flow charts have the file names used for
input, output, update of the files accessed and the names of the reports
that might be created after the program run. It means, program flow
charts contains each and every single details of the program
ADVANTAGES OF FLOW CHARTS
Effective Analysis - Using flow chart, any problem can be analyzed in more
effective way
Communication - Flowcharts are much better way of communicating any logic of
a system to all concerned
Efficient Coding - Every flowcharts acts as a guide or blueprint during the
systems analysis and program development phase
Proper Debugging - The flowcharts helps in debugging process
Efficient Program Maintenance - The maintenance of operating program
becomes very easy using flowcharts.
Proper Documentation - Program flowcharts serve as a good program
documentation, which is needed for various purposes
DISADVANTAGES OF FLOW CHARTS
Complex Logic - Sometime, the given program logic is quit complicated. In that
case, it becomes very difficult task to design or draw a flowchart for that
problem or program. In that case, algorithm helps a lot
Alterations and Modifications - If we want to alter or change any logic of the
program in the flowchart, then we have to re-draw the whole flowchart which is
very irritating.
Examples for Algorithm Flowcharts
Find the sum two numbers N and M
The procedure is:
1. Enter the two numbers in the variables N and M.
2. Sum them and save the result in the variable sum.
3. Output the result.
Examples for Algorithm Flowcharts
Calculate the Interest of a Bank Deposit
Algorithm:
•Step 1: Read amount,
•Step 2: Read years,
•Step 3: Read rate,
•Step 4: Calculate the interest with the
formula "Interest=Amount*Years*Rate/100
•Step 5: Print interest,
Examples for Algorithm Flowcharts
Determine and Output Whether Number N is Even or Odd
Algorithm:
•Step 1: Read number N,
•Step 2: Set remainder as N modulo 2,
•Step 3: If the remainder is equal to 0 then number N is even,
else number N is odd,
•Step 4: Print output.
Examples
for
Algorithm
Flowchart
s
Activity for Algorithm Flowcharts
Write algorithm and draw flowchart to answer the
following activity
How to Buy a Pen
Accept Two Numbers and display greatest among two
numbers
Accept Three Numbers and display greatest among
three numbers
Accept a Number and test if its Even or Odd Number
REFERENCES:
• https://www.c-programming-simple-steps.com/algorithm-examples.html
• https://edrawsoft.com/explain-algorithm-flowchart.html
• https://www.edrawsoft.com/algorithm-flowchart-examples.html
• https://codescracker.com/computer-fundamental/algorithm-and-
flowchart.htm