Professional Documents
Culture Documents
Objectives
Example:
All candidates have to take three tests. A candidate is selected
for the interview round based on the scores of all the three
tests. The individual score in each test has to be greater than
75 and the average score across the three tests should be a
minimum of 80. The call letter for the interview is to be sent to
candidates who have been selected and a rejection letter is to
be sent to the rest. Represent the logic for the above process
by using a flowchart.
Declare Variables
Is
nAverage>= 80 AND No Display “ Rejection
nTest1 > 75 AND letter to be sent”
nTest2 > 75 AND
nTest3 > 75 ?
Yes
Display “Interview
call letter to be sent”
Stop
Iteration
Iteration (Contd.)
Example:
Flowchart to display the sum of ten numbers
Start
numeric nNum,
nSum, nCounter
nCounter=0
nSum=0
Accept nNum
nSum=nSum+nNum
nCounter=nCounter+1
Yes Is No
nCounter<10 ? Display nSum
Stop
Iteration (Contd.)
Iteration (Contd.)
Example:
You have been assigned the responsibility of generating an
address list of all the people working in your office. For each
person, you will need to accept the name, address, and the
telephone number and print a list containing the collated
details.
Iteration (Contd.)
nCounter = 1
Is No
nCounter<=25?
Yes Stop
Accept cName
Accept cAddress
Accept cTelno
Display cName,
cAddress, cTelno
nCounter=nCounter+
1
Ver. 1.0 Session 3 Slide 10 of 29
Programming
Installing WindowsLogic and Techniques
XP Professional Using Attended Installation
Iteration (Contd.)
Example:
Let us look at the same example of preparing the test
performance report in the decision-making section again. Now,
apart from finding out whether a candidate has to be sent a call
letter or a rejection letter, we also have to calculate the number
of candidates who have been sent interview call letters and the
number of candidates who have been sent rejection letters,
using a flowchart.
Iteration (Contd.)
Variable Declaration
Accept Values
Is
nAverage >=80 AND No
nTest1 > 75 AND nTotReject=nTotReject+1
nTest2 > 75 AND
nTest3 > 75 ?
Yes
nTotSelect=nTotSelect+1
Process
A B
Iteration (Contd.)
B
A
Accept cChoice
Is
No
cChoice = “Y”?
Stop
Iteration (Contd.)
Main
Program
Example:
Flowchart to show modular programming
Start
nSum=nNum1 + nNum2
Accept nNum1, + nNum3
nNum2, nNum3
Return
Add
Display nSum
Stop
Example:
Accept the test scores for 10 students and display their
individual averages. The scores of the students cannot be
negative.
The table shows the variables used in the flowchart.
Variable Data Type Variable Name
Accept cStudentName
Accept Average
Accept nTest1
nAverage=(nTest1+nTest2
Average Accept nTest2 +nTest3) / 3
No Return
Example:
The total expenditure on salaries for the month needs to be
calculated. As per company policy an employee receives a
minimum of $500. Depict the logic for automating the task by
using flowcharts.
The table shows the variables used in the flowchart.
Accept
Is No Summation
cChoice = “Y” ? Accept nSalary
Yes
nTotSalary=nTotSalary+nSalary
Is Yes
Accept nSalary >=500 ?
Return Return
No
Summation Display ”Salary cannot
be less than $500”
Exercises
Exercise 1
Exercise 2
Exercise 3
Exercise 4
Summary
Summary (Contd.)