Algorithm and Flowchart-4
Algorithm and Flowchart-4
FLOWCHART
ARCHANA MENON P
archananirmal1414@gmail.com
Agenda
• Algorithm
• Flowchart
• Pseudocode
• Control structures
• Examples
• References
STEPS IN PROBLEM SOLVING
Algorithm
Step 1: Start
Step 2: Read A, B
Step 3: S= A + B
Step 4: Display Sum 'S'
Step 5: Stop
Algorithm
Pseudocode:
I n p u t a set of 4 m a r k s
Calculate their average by summing a n d dividing by 4
if average is below 50
P r i n t “FAIL”
else
P r i n t “PASS”
Flowchart:
START
Algorithm:
PRINT P RINT
“PAS S” “FAIL”
S TOP
Control Structures
• Control Structures specifies the flow of control in programs.
• It analyzes and chooses in which direction a program flows based on certain
parameters or conditions.
• There are three basic types of logic, or flow of control, known as:
Sequence logic, or sequential flow
Selection logic, or conditional flow
Iteration logic, or repetitive flow
Control Structures
Sequential Logic (Sequential Flow)
• Sequential logic as the name suggests follows a serial or sequential flow in which the flow depends on the
series of instructions given to the computer.
• Unless new instructions are given, the modules are executed in the obvious sequence.
• The sequences may be given, by means of numbered steps explicitly.
• Also, implicitly follows the order in which modules are written.
• Most of the processing, even some complex problems, will generally follow this elementary flow pattern.
• It is a continuous set of actions where one is followed by another till the expected result is
obtained.
Statement 1
Statement 2
Statement 3
...
Statement n
SEQUENTIAL FLOW
Control Structures
Selection Logic (Conditional Flow)
Selection Logic simply involves a number of conditions or parameters which decides one
out of several written modules. The structures which use these type of logic are known
as Conditional Structures.
It is used in conditional execution.
When you take some action based on the results of logical test, that is a selection
construct.
If (condition)
True statements;
Else
False statements;
Endif
CONDITIONAL FLOW
Control Structures
Iteration Logic (Repetitive Flow)
• The Iteration logic employs a loop which involves a repeat statement followed by a module
known as the body of a loop.
• Iteration is repetitive execution of consecutive instructions.
• It is also called looping.
• It may either be conditional or unconditional looping.
REPETITIVE FLOW
Control Structures
EXAMPLE
Wr it ea n a lgorit h m a n d d ra w a flowch a r t to
convert the length in feet to centimeter.
Pseudocode:
P rin t
Lcm
S TO P
Flowchart
1. Draw a flowchart to read a number and find the sum with its previous number.
2. Draw a flowchart to check if the given no. is positive or not?
3. Write an algorithm and draw a flowchart to find the biggest no from 2 given
numbers.
4. Write an algorithm and draw a flowchart to find the sum of first N real numbers.
5. Write an algorithm and draw a flowchart to find the sum of first n odd numbers.
6. Write an algorithm and draw a flowchart to find the biggest among 3 numbers.
Flowchart
Solution:4
How to write an algorithm
Refer this mannual to learn how to write algorith and draw flowchart.
• http://www.yspuniversity.ac.in/cic/algorithm-manual.pdf
References
• https://www.slideshare.net/ijs2k8/programming-in-c-70043397
• https://www.slideshare.net/gauravjuneja11/c-language-ppt
THANK YOU