Algorithm and Flowchart
Algorithm and Flowchart
Computer ScenceandEagineering
0 ntrodiuction
A computersavery powerful and versatile machine capableofperfoming
a multitude of differenttasks,yet it has no intelligence or thinking power The
intelligence Quotient (T.Q) ofa computer is zero. Acomputer performs many
tasks exactly in the same manner as it is told to do. This places responsibi
on
the user to instruct the computer in a correct and precise manner, so that the
is
machine able to perform the required job in a proper way. A wrong or
ambiguous instruction may sometimes prove disastrous.
Introduction to Problem Solving he computer to soBve the problem becomes relatively easier task.
Techniques Thus, before attempt to write a computer program to solve a given problem.
It is necessary to formulate or define the problem in a precise manner. Once the
problem is defined, the steps required to solve it, must be stated clearly in the
required order.
Step1. Identification of input For an algorithm, there are quantities to Step 2 Compute the sum of a, band c
be supplied called input and these are fed
first for any spec1tied
extemaly The
input isto be indentified Step 3 Divide the sum by3
problem
Step 4 Store the result in variable d
Step2: Identification ofoutput: From an algorithm, at east one quantity
Is produced, called for Step 5 Print the value of d
any specified problem
Step3: ldentification the processing operations All the Step 6 End of the program
to be calculations
perfomed in order to ead to output from the input are to be identified in 1.2.2 Algorithms for
an orderty manner. Simple Problem
Write an algorithm for the following
Step4: Processing Definiteness The instructions
algorithm must be clear and there should not be any ambiguity incomposing
the
I. Write an
them algorithm to calculate the simple interest using the formula.
Simple interest= p*N* R/100.
254 Compater Sdence and Eagineering
Paper Programmingin C 23
4. Write down an algorithm to find the largest data value of a set of given
Where Pis principle Amount, N is the number ofyears and R is the rate data values
of interest
Step 8 end
Compater Scienceand Engíneering
256
in C
Paper Programam ing 255
Step S: Print perimeter.
6 Write algorthm to find the factorial ofa given number N
Step 6: Print area.
Step 1 PROD-1|
Step 7: Stop
Step2 1-0
START
d Decision Makers: The diamond is used for indicating the step of
decision making and therefore knowm as decision box Decision boxes are used
to test the conditions or ask questions and depending upon the answers, the NPUT AB,C
approprate actions are taken bythe computer. The decision box symbol is
D--4A*C
D-O
NO
2A TA
£ On-Page connectors: Circles are used to join the different parts ofa Priat XY7
flowchart and these circles are called
on-page connectors. The uses
of these
connectors grve a neat shape to the flowcharts. Ina complicated problems, a
Towchart may run in to several The
pages. ofthe
parts on different
flowchart Stop
260 2 Computer Science and Engineering
Programming in C 259
Paper
4. Draw a flowchart to find the factorial of given positive integer N.
2. Draw aflowchart to find out the biggest of the three unequal positive
numbers. START
START
iNPUT
PROD=1
NO
YES
PROD
STOP
LPROD= PROD *1I
5. Develop a flowchart to illustrate how to make Land
3. Draw a flowchart for adding the integers from 1 to 100 and to
a phone
telephone call
print the sum.
TALK TO THE
SIAR PERSON AT THE
START OTHER END
DIAL THE
NUMBER STOP
START
Model Ouestions
Short Answer p e Questions2Mark
***********xensoek***********************
* * * ** * * * *
1.5Pieudo code . e . . .
2. Write an algorithm to find greatest ofgiven three numbers
The Pseudo code is neither an algorithm nor a program. is an 3. Write an algorithm to check whether given integer value is PRIMEor
It abstract NOT.
form ofa program. It consists of English like statements which perform the
specific operations. It is defined for an algorithm. It does not use any graphical 4. Draw the fowchart to find roots ofQuadratic equation ax+ bxt c=0
representation. In pseudo code, the program is represented in terms of words
and phrases, but the syntax of program is not strictly followed. Note Practice more related Algorithms and Flowchars
Advantages: *
Easyto read, Easy to understand,* Easy to modify
Example: Write a pseudo code to perfom the basic arithmetic operations.
Read nl, n2
Sum=nl +n2
Diff=nl -n2
Mult =nl* n2
Quot nl/n2
End