Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

B.1 Types of Flowcharts: Saturday, 29 August 2020 1:13 PM

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Saturday, 29 August 2020 1:13 pm

A. Flow Charts

• Define and analyze


• Build step by step picture of a process
• To find the areas of improvement in the process

Advantages
• Communication – it is better way of communicating the logic of a program solution.
• Effect analysis – with the help of flow charts problem can be analyze in a effective way
• Effective coding – flow charts acts as a blue print during the system analysis iv. Proper debugging – flow chart helps in
debugging process.

Limitations
• Alterations and modifications: If alterations are required, the flowchart may require re -drawing completely.

B.1 Types of Flowcharts

Flow charts can be broadly classified in to two types


1. System flow charts: These are used by system analyst to describe the data flow and operation in a data processing
cycle. System flow chart defines the broad processing in organizations showing the origin of data filing structure,
processing to be performed and output to be generated.

2. Program flow charts: Program flow charts are used by programmers. It is used to describe the sequence of
operations and decisions for a particular problem. Generally to solve any of the programs belonging to C, C++, Java. .
etc., program flow charts are used.

B.2 Symbols Used in Flowcharts


The flow chart being symbolic representation standard symbols is used for each specific operation. These symbols
are used to represent the sequence of operations and flow of data and documents required for programming. Flow
should be from top to bottom. The most commonly used symbols are shown in the figure 1.1

B.3 Writing Expressions in Computer Language


1. To read the input ;
Read a
1.1 The following symbol is used to read one or more inputs.

1. Here ‘a’ is the variable where the value of Input is stored.

Programming Logic and Design Page 1


2. To produce output :
1. The following symbol is used to print one or more outputs.
Print a

1. Here ‘a’ is the variable where the value of Output is stored.

3. Assignment operator The result of arithmetic operation is stored in a variable. This is represented as below. This is
illustrated in example 1.10

Let a and b be inputs


Operation → addition
Result is stored in variable c
c=a+b

Examples:

1. Fahrenheit Scale Convert into Celsius Scale


Solution:
Formula: C = (F-32)/1.8
where F is Fahrenheit value and C is Celsius value.

2. Draw a flowchart that will compute and print the area of the circle assuming that the radius is equal to 5.

Programming Logic and Design Page 2


leni.bulan@ub.edu.ph at 31/08/2020 4:22 pm

3. Draw a flowchart that will read two integers. Compute and print the sum and product of these numbers.

4. Draw a flowchart to find greater of 2 numbers

5. A Class has four exams. Draw a flowchart that will read in the value of the four exams and output the student’s
average.

Programming Logic and Design Page 3


6. Draw a flowchart that determines if an inputted number is odd or even.

1. Draw a flowchart that will determine a student’s grade


based on four major exams. The flowchart should
compute for the average of four major exams and identify
his grade based on his average. Use the following criteria:
Average Grade Remarks
99-100 A+ Excellent
96-98 A- Very Good
93-95 B+ Very Good
90-92 B- Good
87-89 C+ Good
84-86 C- Fair
81-83 D+ Fair
78-80 D- Passed
75-77 E Conditional
Below 75 F Failed

Printout the student’s name, his average, letter grade


and remarks.

Programming Logic and Design Page 4


Programming Logic and Design Page 5
Learning Activity 1: Algorithms and Flowcharts

Write an algorithm and draw the flowchart for each of the following:
1. Draw a flowchart that will compute for the perimeter of the circle. Given the formula
P = 2*pi*R
Where P is the perimeter, r is the radius.

2. An Auto mobile starts from rest then runs at a speed of a km/hr. Draw a flowchart that will compute for the total
distance traveled if the automobile had been traveling for t hours. Use the formula d=v0t + (at2)/2

Programming Logic and Design Page 6


3. Draw a flowchart that that will identify if a number entered is negative or positive.

4. Draw a flowchart that will accept three numbers and determines which is the highest and which is the lowest.

5. Draw a flowchart that will compute and print for the price of ice given the following conditions
Temperature Price(pesos)
35-37 5
31-34 4
27-30 3
24-26 2
23 and below 0

Programming Logic and Design Page 7


Programming Logic and Design Page 8
Basic Control Structure of a Flowchart
Most of the times some part of the program needs to be repeated at a specified number of times or until a condition is
satisfied, the process is called looping. It makes the flow of control in a program dependent on the value of the
specified condition.

1. Sequence (begin..end or start..stop)


In this kind of structure the steps involved follow each other one after It should be noted however that every flowchart
begins and ends with this kind of notation.

2. Decision (if..then..else)
Part of the flowchart that employs two or more possible alternative solution and one of which will be chosen for
execution depending on the value of the given condition.
Example:

3. Loop (while..do, repeat ..until)/Iteration


Loop is part of the flowchart that repeats at a specified number of time. This process is called looping. It can be made
to stop when a certain condition is met or stop at a specified number of repetitions. A counter is needed to keep track
at the number of times a loop is executed. Failure to set the condition will cause the loop to iterate indefinitely.

In a Repeat...Until loop, the process is executed first then the condition is tested. If the value of the condition returns

Programming Logic and Design Page 9


In a Repeat...Until loop, the process is executed first then the condition is tested. If the value of the condition returns
False the control is returned to repeat the process; otherwise the True statement is executed

Note: Counters are usually initialized at the beginning of the program

Designing a Loop
There are three things to consider in designing a loop:
1. The body
2. The initializing statement
3. The conditions for terminating a loop

Methods for Terminating a Loop


There are various ways of terminating a loop. Each way depends on the given condition of the problem

1. Count controlled loop


The user ask for the number of times a loop is to be repeated.

2. Ask before iterating


The user is prompted after each loop whether or not a loop is iterated again

3. Using a sentinel value


The user assigns a sentinel value to terminate a loop. Sentinel has a value that is distinct so that it will indicate the
end of the loop. A good example is when a program reads in positive integers, a negative number can be used as a
sentinel value.

4. Running out of input


A loop that runs out of input will terminate with an error.

5. Exit on a Flag condition


This condition uses a variable that changes its value to indicate that some event has taken place.

Examples (Looping and Iteration)


1. Write a flowchart to add natural numbers from 1 to 50

2. Draw a flowchart that add first N numbers

Programming Logic and Design Page 10


3. Draw a flowchart that accepts 10 numbers. Determine if the numbers entered are odd or even. Compute for the total
of all odd numbers, all even numbers, and the total of all numbers.

Programming Logic and Design Page 11


1. Write a flowchart to add natural numbers from 1 to
50 `

2. Draw a flowchart that add first N numbers

Programming Logic and Design Page 12


1. Draw a flowchart that accepts 10 numbers.
Determine if the numbers entered are odd or even.
Compute for the total of all odd numbers, all even
numbers, and the total of all numbers.

1. Flowchart that accepts a number then output the


sum of the squares from 1 to n.

Programming Logic and Design Page 13


1. Flowchart that will compute for the sum of even
numbers until a number 1 is entered.

Programming Logic and Design Page 14

You might also like