You are on page 1of 8

Lab Manual

Fundamentals of Algorithms
CS – 201

Instructor
Ms. Saher Naqi

Submitted By
Mr. Muhammad. Irfan Arshad
Roll Number: 1387
BS – CS (3rd Semester)

College of Computer Sciences and Information Studies


Government College University, Faisalabad.
Page 1 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts
Problem’s Solution via pseudo code
Problem Statement 1:
A student appears in an examination that consists of total
10 subjects, each subject having maximum marks of 100. The roll number of the
student, his name, and the marks obtained by him in various subjects is supplied as
input data. Such a collection of related data items that is treated as a unit is known
as a record. Draw a flow chart for the algorithm to calculate the percentage marks
obtained by the student in this examination and then to print it along with his roll
number and name.

ALGORITHM 1 student_marks (Array, length)


Input: Enter a (name, roll#, marks{m1,m2,……m10})
Output: Display a percentage along with his roll# & name
total 0
for i 0 to Array[length]
do
total total Array[marks]
end
percentage (total/10)*100

return percentage

Problem Statement 2:
50 students of a class appear in the problem 1. Draw a
flowchart for the algorithm to calculate and print the percentage marks obtained by
each student along with his roll number.

10/28/2010 7:47 PM BY M.IRFAN ARSHAD


Page 2 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts

Problem Statement 3:
Draw a flow chart of the logical steps needed to produce
a printed listing of all students over the age of 20 in a class. The input records
contain the name and age of the students. Assume an initial value of 99 for the age
field.

START

Enter a Name & age

If
age >20

Yes

Process on data

Display name &age

STOP

10/28/2010 7:47 PM BY M.IRFAN ARSHAD


Page 3 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts

Problem Statement 4:
Draw a flowchart of the logical steps needed to print the
name and age of the oldest and the youngest student in a class. The input records
contain the name and age of the students.

START

Enter a Name & age

Check which student is


young which is old

Youngest Oldest

Process on data Process on data


& loop & loop

Display Young name &age Display Young name &age

STOP

10/28/2010 7:47 PM BY M.IRFAN ARSHAD


Page 4 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts

Problem Statement 5:
A set of examination papers which have been graded with
scores from 0 to 100 is to be searched to find how many of them are above 90. The
total is to be printed.

START

Enter scores
(0-100)

If
Yes scores >90 Loop

No
Add total marks

Display total marks

STOP

10/28/2010 7:47 PM BY M.IRFAN ARSHAD


Page 5 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts

Solution of Review Questions:


What is a flowchart?
A flowchart is a type of diagram that represents an algorithm or process,
showing the steps as boxes of various kinds, and their order by connecting these with arrows.
This diagrammatic representation can give a step-by-step solution to a given problem. Data is
represented in these boxes, and arrows connecting them represent flow / direction of flow
of data. Flowcharts are used in analyzing, designing, documenting or managing a process or
program in various fields.
How does a flowchart help a programmer in program development?
The flowchart is a means of visually presenting the flow of data through
an information processing systems, the operations performed within the system and the sequence
in which they are performed. In this lesson, we shall concern ourselves with the program
flowchart, which describes what operations (and in what sequence) are required to solve a given
problem. The program flowchart can be likened to the blueprint of a building. As we know a
designer draws a blueprint before starting construction on a building. Similarly, a programmer
prefers to draw a flowchart prior to writing a computer program . Flow chart is pictorial
representation of the flow of the program, algorithm is step by step procedure to solve a given
problem.
What are the characteristics necessary for a sequence of instructions to
qualify as an algorithm?
Algorithms are essential to the way computers process information, because a
computer program is essentially an algorithm that tells the computer what specific steps to
perform (in what specific order) in order to carry out a specified task, such as calculating
employees' paychecks or printing students' report cards. Thus, an algorithm can be considered to
be any sequence of operations which can be performed by a Turing-complete system. Therefore,
while designing an algorithm care should be taken to provide a proper termination for
algorithm. Thus, every algorithm should have the following five characteristic features 

1.Input 
2.Output 
3.Definiteness 
4.Effectiveness 
5.Termination 

Therefore, an algorithm can be defined as a sequence of definite and effective instructions, which
terminates with the production of correct output from the given input. 

In other words, viewed little more formally, an algorithm is a step by step formalization of a
mapping function to map input set onto an output set. 

10/28/2010 7:47 PM BY M.IRFAN ARSHAD


Page 6 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts

Describe the function of the various flowcharting symbols?

Symbol Symbol Symbol Description


Name
(alias)

Process Show a Process or action step. This is the most


common symbol in both process flowcharts and
business process maps.
Predefined A Predefined Process symbol is a marker for another
Process process step or series of process flow steps that are
(Subroutine) formally defined elsewhere. This shape commonly
depicts sub-processes (or subroutines in
programming flowcharts). If the sub-process is
considered "known" but not actually defined in a
process procedure, work instruction, or some other
process flowchart or documentation, then it is best
not to use this symbol since it implies a formally
defined process.
Flow Line  Flow line connectors show the direction that the
(Arrow, process flows.
Connector)
Decision Indicates a question or branch in the process flow.
Typically, a Decision  flowchart shape is used when
there are 2 options (Yes/No, No/No-Go, etc.)

Connector Flowchart: In flowcharts, this symbol is typically


(Inspection) small and is used as a Connector to show a jump
from one point in the process flow to another.
Connectors are usually labeled with capital letters
(A, B, AA) to show matching jump points. They are
handy for avoiding flow lines that cross other shapes
and flow lines. They are also handy for jumping to
and from sub-processes defined in a separate area
than the main flowchart.
Process Mapping: In process maps, this symbol is
full sized and shows an Inspection point in the
process flow.

10/28/2010 7:47 PM BY M.IRFAN ARSHAD


Page 7 of 8 cs-102

BS (cs) - Lab Manual Lab 1:


Flowcharts
[Just to confuse things further, some people will use
a circle to indicate an operation and a square to
indicate an inspection. That's why it's important to
include a symbol key in the flowchart.]
Data The Data flowchart shape indicates inputs to and
(I/O) outputs from a process. As such, the shape is more
often referred to as an I/O shape than a Data shape.
What is a record?

In computer data processing, a record is a collection of data items arranged


for processing by a program. Multiple records are contained in afield or data set. The
organization of data in the record is usually prescribed by the programming language that defines
the record's organization and/or by the application that processes it. Typically, records can be of
fixed-length or be of variable length with the length information contained within the record.

10/28/2010 7:47 PM BY M.IRFAN ARSHAD

You might also like