Flowcahrt Tatourial - CS 240 - Computer Programming in C++ I

Report
Flowchart Tutorial
Start or end of the program
Computational steps or processing
function of a program
Input or output operation
Decision making and branching
Connector or joining of two parts of
program
Example 1:
Draw a flowchart to find the
sum of first 50 natural
numbers.
start
SUM=0
N=0
N=N+1
SUM=SUM+N
no
IS
N==50?
yes
Print SUM
END
Example 2
Draw a flowchart to find the
largest of three numbers A, B,
and C.
START
READ A,B,C
yes
IS
B >C ?
no
IS A>B
?
yes
IS
A>C ?
yes
no
no
PRINT C
PRINT B
END
PRINT A
Example 3
Draw a flowchart for program
Find the difference and the
division of two numbers and
display the result.
START
READ N1 , N2
D=N1-N2
V=N1/N2
PRINT D , V
STOP
Example 4
Draw a flowchart for program
Print the first 10 natural
number
start
N=1
Print N
N=N+1
yes
while
N <= 10
no
END
Example 6
Draw a flowchart for program Calculate the
student grade ( A,B,C,D,F)
start
Read Grade
Print
A
yes
Grade
>=90
no
Print
B
yes
Grade
>=80
no
Print
C
yes
Grade
>=70
no
Print
D
yes
Grade
>=60
no
END
Print
F
Example 7
Draw a flowchart for program read
temperature , If temp > 0 print above
freezing else below freezing
start
Read Temp
Print“above
freezing”
yes
Temp >0
no
Print“below
freezing”
End
Example 8
Draw a flowchart for program
read (10) marks for (20)
students, then print the
average for each student.
START
studentCount=0
markCount=0
sUM=0 , avg=0
no
While
studentCount
<20
STOP
yes
While
markCount<
10
no
avg=sUM/10
yes
READ x
PRINT avg
Increment
studentCount
sUM=sUM+x
Increment markCount
avg=0 , sUM=0
markCount=0

similar documents