Lab Task 1 - Programming Logic, Pseudocode, Flowchart
Lab Task 1 - Programming Logic, Pseudocode, Flowchart
Lab Task 1 - Programming Logic, Pseudocode, Flowchart
Let us recall that the programming process follows a program development lifecycle with its
initial steps as understanding the problem and planning the logic. This session focuses on
‘planning the logic’ where we will learn how to develop an algorithm in the form of pseudocode
or flowchart.
Objectives
After completion of this lab session, you will have gained fundamental skills to plan the logic of
a program by ways of developing an algorithm in the form of pseudocode or flowchart.
Tools/Software Requirement
Description
Introduction to Algorithms
An algorithm is basically a procedure of steps that we exactly follow to solve a particular task or
problem. We can say that it is a set of rules that we need to follow while developing a program
code during problem-solving. Furthermore, if we write an algorithm before actually writing a
Features of an algorithm:
Clarity: The algorithm should be very clear and unambiguous in its meaning. It should be simple
so that one can understand it easily.
Well-defined inputs: A program may require to take input from the user. Therefore, the algorithm
should clearly define the inputs.
Well-defined outputs: The algorithm should clearly specify the output that the program will
produce.
Finiteness: The algorithm should have a termination point. This means that the algorithm should
not be such that it runs infinite times or end up in loops.
Feasibility: The algorithm should be such that we can implement it easily. Hence, it should be
simple and practical to implement.
Language independent: It should be in simple English language. Since the code implementation
should result in the same output no matter which programming language we use while writing
the code.
Introduction to Flowcharts
Symbols in a flowchart
The flowchart uses various symbols in the representation. These basic symbols are as follows:
Terminal: It represents the start, stop, or halt in a program’s flow. The flowchart always starts and
ends with this symbol. Besides, we represent it using an oval shape.
Input/Output: We represent it using a parallelogram. It indicates any input from the user or
output of the program.
Connectors: We represent it using a circle. Whenever a flowchart is too large, we can use
connectors to avoid confusion.
Flow lines: These are basically arrows that represent the flow of the program.
Example:
We will be using the Visual Logic tool to draw the flowchart. Below, we see the symbols used by
Visual Logic associated to various actions performed in an algorithm. Remember that these
shapes are arbitrarily assigned and there is no hard and fast rule about this association. In the
case of Visual Logic, you do not need to remember the shape associations as these are created
automatically.
Example flowchart drawing: draw a flowchart to take two numbers as input from keyboard,
compare the two numbers, and show an output about which number is greater. Your flowchart
should look like the one below:
Instructions
Using Microsoft Word on computer to write pseudocode and the Visual Logic software to draw
flowchart, develop the logic for each of the following problems. Use Snipping Tool to copy the
flowchart from Visual Logic as an image. Insert this flowchart image into Microsoft Word. Crop
the image adequately in Microsoft Word. You must show the execution of at least one flowchart
in Visual Logic to the TA, along with your Word document to get your work graded.
Deliverables
Compile a single Word document by filling in the solution part and submit this Word file.
Lab Tasks
Q1) Develop the logic of a program that allows the user to enter two values and displays their sum and
difference.
Answer:
Solution: Pseudocode
Develop the logic of a program that allows the user to enter two values and displays their sum
and difference.
Algorithm
Solution: Flowchart
Answer:
Solution: Pseudocode
Calculate the area and circumference of a circle.
Algorithm
Solution: Flowchart
Introduction to Programming Page 7
Lahore Garrison University
Digital Forensic Research and Service Center
Answer:
Solution: Pseudocode
Solution: Flowchart
Q4) Write a program to compute the sum of the two given integer values. If the two values are the same,
then return triple their sum.
Introduction to Programming Page 8
Lahore Garrison University
Digital Forensic Research and Service Center
Answer:
Solution: Pseudocode
Solution: Flowchart
Q5) Write a program to check two given integers, and return true if one of them is 30 or if their sum is 30.
Answer:
Solution: Pseudocode
Solution: Flowchart
Answer:
Solution: Pseudocode
Solution: Flowchart
Q7) Write a program to output alarm if given temperature in higher than 72 degrees. If not prompt
successful execution.
Answer:
Solution: Pseudocode