Course – PROBLEM-SOLVING
THROUGH PROGRAMMING
Course Instructor
Dr. Umadevi V
Department of CSE, BMSCE
Webpage:https://sites.google.com/site/drvumadevi/
February 25, 2024 CSE, BMSCE 1
Unit-1
Introduction to Computer Hardware
and Software: Algorithms and flowchart.
February 25, 2024 CSE, BMSCE 2
What is an Algorithm ?
Algorithm is a step – by – step procedure which is helpful in solving a
problem. If, it is written in English like sentences then, it is called as
‘PSEUDO CODE’.
Properties of an Algorithm
Input: An algorithm may or may not require input
Output: Each algorithm is expected to produce at least
one result
Definiteness: Each instruction must be clear and
unambiguous.
Finiteness: If the instructions of an algorithm are
executed, the algorithm should terminate after finite
number of steps
February 25, 2024 CSE, BMSCE 3
Example
Algorithm to find the sum of two numbers
Step-1: Start
Step-2: Input two numbers say A and B
Step-3: Compute SUM = A + B
Step-4: Display SUM
Step-5: Stop
February 25, 2024 CSE, BMSCE 4
Example
Algorithm to find Area and Circumference of Circle
Step-1: Start
Step-2: Input Radius of Circle say R
Step-3: Area = 3.142 x R x R
Step-4: Circumference = 2 x 3.142 x R
Step-5: Display Area, Circumference
Step-6: Stop
February 25, 2024 CSE, BMSCE 5
Flowchart
A flowchart is a diagrammatic representation of
an algorithm. A flowchart can be helpful for
both writing programs and explaining the
program to others.
February 25, 2024 CSE, BMSCE 6
Symbols Used In Flowchart
Symbol Name Symbol Description
Oval Used to represent start and end of
flowchart
Parallelogram Used for input and output
operation
Rectangle Processing: Used for arithmetic
operations and data manipulations
Diamond Decision making. Used to
represent the operation in which
there are two/three alternatives,
true and false etc.
Arrows Flow line Used to indicate the flow
of logic by connecting symbols
February 25, 2024 CSE, BMSCE 7
Example
Flow chart to find the sum of two numbers
February 25, 2024 CSE, BMSCE 8
Example
Flowchart to find area and circumference of a circle.
February 25, 2024 CSE, BMSCE 9
Algorithm and Flowchart to find Largest of two numbers
Algorithm
Step-1: Start
Step-2: Input two numbers say NUM1,NUM2
Step-3: IF NUM1 > NUM2 THEN
print largest is NUM1
ELSE print largest is NUM2
ENDIF
Step-4: Stop
February 25, 2024 CSE, BMSCE 10
Algorithm and Flowchart to find Largest of two numbers
Algorithm
Step-1: Start
Step-2: Input two numbers say NUM1,NUM2 Flowchart
Step-3: IF NUM1 > NUM2 THEN
print largest is NUM1
ELSE print largest is NUM2
ENDIF
Step-4: Stop
February 25, 2024 CSE, BMSCE 11
Flowchart to find the largest of three numbers
Input Value
February 25, 2024 CSE, BMSCE 12
Algorithm to find the largest of three numbers
February 25, 2024 CSE, BMSCE 13
Algorithm and Flowchart to find whether given number is Even or Odd
Algorithm Flowchart
Step-1: Start
Step-2: Input number say NUM Start
Step-3: Remainder=NUM%2
Step-3: IF Remainder == 0 THEN Enter NUM
Print Even
ELSE
Remainder= NUM % 2
Print Odd
ENDIF
Step-4: Stop
True If False
Remainder ==0
Print Even
Print Odd
Note:
% is a remainder Operator,
Which returns the remainder value
Stop
February 25, 2024 CSE, BMSCE 14
Algorithm & Flowchart to Swap Two Numbers using Temporary Variable
February 25, 2024 CSE, BMSCE 15
Thanks for Listening
My contact details
Dr. Umadevi V, Associate Professor, Department of CSE, BMSCE
Staff Room: 4th floor, New Academic block
umadevi.cse@bmsce.ac.in
8762742909
February 25, 2024 CSE, BMSCE 16