0% found this document useful (0 votes)
14 views

Lecture15

Uploaded by

astroprogram111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture15

Uploaded by

astroprogram111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Lecture # 15

CSE-1010 :Programming I

Transforming Education. Enriching Lives

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 1


What will cover today?
• Introduction to Flow Chart

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 2


Flow Chart
• A flowchart is a type of diagram that represents a workflow or process.
• A flowchart can also be defined as a diagrammatic representation of an
algorithm, a step-by-step approach to solving a task.
• The flowchart shows the steps as boxes of various kinds, and their order by
connecting the boxes with arrows.
• This diagrammatic representation illustrates a solution model to a given problem.
• Flowcharts are used in analyzing, designing, documenting or managing a process
or program in various fields.[1]
• Help visualize what is going on and thereby help understand a process, and
perhaps also find less-obvious features within the process, like flaws and
bottlenecks.

Types of flow charts
• Document flowcharts, showing controls over a document-flow
through a system
• Data flowcharts, showing controls over a data-flow in a system
• System flowcharts, showing controls at a physical or resource level
• Program flowchart, showing the controls in a program within a
system

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 4


Basic Flow Chart Symbols
6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 6
Flow chart for Looping

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 7


Example1:
Write an algorithm for finding if a given number is even or odd or
express it in flowchart.
Step1:start
Step2: accept the number from the user
Step2: Store the number in Number
Step3:Divide the Number by 2, If the remainder is 0 Display ‘Even'
otherwise display ‘Odd'
Step4: stop

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 8


Algorithm
Step1:start
Step2:Input number
Step3:Set remainder=number mod 2
Step4:If remainder=0
Step5:display number is even
Step6:stop
Step6: display number is odd
Step7:stop

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 9


Flow Chart
Start

false
Input a number Display ‘Odd’

Remainder=Number if
mod 2 Remainder
=0
true
Display
‘Even’

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I Stop 10


Rules for Flow Chart
• All symbols of the flowchart are connected by flow lines (note arrows,
not lines)
• Flowlines enter the top of the symbol and exit out the bottom, except
for the Decision symbol, which can have flow lines exiting from the
bottom or the sides
• Flowcharts are drawn so flow generally goes from top to bottom
• The beginning and the end of the flowchart is indicated using the
Terminal symbol

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 11


Another example
Step1:start
Step2:input myNumber
Step3:set myAnswer=myNumber*2
Step4:output myAnswer
Step5:stop

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 12


Start
Flow Chart
Enter myNumber

myAnswer=myNumber *2

Display
myAnswer

Stop
6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 13
Another example
• Step 1: Get the weight of object in kilograms as input data.
• We will call this as weight_in_kilos.
• Step 2: Calculate weight_in_pounds using the formula, weight_in_pounds
= weight_in_kilos * 2.20 This used the fact that 1 kilo is equal to 2.20
pounds.
Step1:start
Step2:input weight_in_killos
Step3:set weight_in_pounds=weight_in_killos*2.20
Step4:output weight_in_pounds
Step5:stop

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 14


Another Example
Convert the temperature given in degrees Fahrenheit to degrees Celsius.
Step 1: Get as input data, the value in degrees Fahrenheit. Let us call it
fahrenheit.
Step 2: Calculate degrees Celsius using the formula,
celsius = 5 * (fahrenheit –32) / 9
Step1:Start
Step2:input fahrenheit
Step3:set celsius=5 * (fahrenheit –32) / 9
Step4:output Celsius
Step5:Stop
6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 15
Another Example
• Step 1: Get the positive integer n as input.
• Step 2: Check if it is divisible by all integers j between 2 and n-1
• Step 3: If n is divisible by any integer j where (2 <= j <= n-1), then the
integer n is not a prime number.
• Else n is a prime number.

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 16


Step1:start
Step2: Get the input number n
Step3: f=0
Setp4: Check if it is divisible by all integers i between 2 and n-1
Step4.1: for i=2 to n-1
Step4.1.1 : if n mod i ==0 then
Step4.1.1.1: set f=1 and break
Step5: If f=0 then
Step5.1.1: output ‘Prime’
Step6: Else ‘Not prime’
Step7:Stop

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 17


Start

Input n

i<=n-
i=2,f=0 i=i+1
1

no
If
n%i N%i=
=0
yes
no
F=1 Display
‘prime’
yes
Display
‘not Stop
6/8/2022 prime’
MIIT, Mandalay, CSE-1010 Programming I 18
References

Online content
Prof. KRV “Raja” Subramanian, Prof Usha Subramanian, "Introduction
to Computing",Courseware for CSE 1010 Programming

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 19


Learning to write programs stretches your mind, and helps you think
better, creates a way of thinking about things that I think is helpful in
all domains.”

—Bill Gates, Co-Chairman, Bill & Melinda Gates Foundation, Co-Founder, Microsoft

6/8/2022 MIIT, Mandalay, CSE-1010 Programming I 20

You might also like