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

Module 2 - Flowcharts, Algorithms Pseudo-Codes

The document discusses modules for flowcharts and algorithms. It covers the steps of programming practices, what flowcharts are, how to make them and examples. It also discusses algorithms, their uses, examples of imperative, conditional and iterative logic constructs.

Uploaded by

KHUSHI GUPTA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Module 2 - Flowcharts, Algorithms Pseudo-Codes

The document discusses modules for flowcharts and algorithms. It covers the steps of programming practices, what flowcharts are, how to make them and examples. It also discusses algorithms, their uses, examples of imperative, conditional and iterative logic constructs.

Uploaded by

KHUSHI GUPTA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Module 2 – Flowcharts &

Algorithms
BITS Pilani Dr. Jagat Sesh Challa
Pilani Campus
Department of Computer Science & Information Systems
Module Overview

• Steps of Programming Practices

• Flowcharts

• Algorithms

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus

Steps of Programming Practices


Steps of Programming Practices
• Step1: Requirements

• Step2: Creating a flow chart

• Step3: Creating algorithms

• Step4: Writing Code

• Step5: Debugging

• Step6: Documentation
Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus

Flowcharts
Steps of Programming Practices
• Step1: Requirements

• Step2: Creating a flow chart

• Step3: Creating algorithms

• Step4: Writing Code

• Step5: Debugging

• Step6: Documentation
Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Flow Chart
• Graphical representation of a solution to a particular problem

• Created by Von Neumann in 1945

• Symbolic diagrams showing data flow, control flow and the


solution of a problem

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Uses of a Flow Chart
• Important for devising a solution to a problem

• Sequence of a program

• helps in developing a logic and algorithms before writing a


program

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
How to make a flow chart
Step1: Identify input and output.

Step2: Apply reasoning skills to solve the problem

Step3: Draw the flowchart using the appropriate symbols and


arrows to show the sequence of steps in solving the problem

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Symbols used in Flow Charts

 Start and End Symbol


 Single Flow Lines

 For Input and Output


 2 Flow Lines

 Process Calculation
 2 Flow Lines

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Symbols used in Flow Charts (contd.)

 Flow Line
 Shows the logical flow of
control

 Decision Symbol
 One flow of line for Input and
two for Output

 Connector
 Connects separate portions
of a flow chart

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Flow Chart Example 1:
Software Development

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Flow Chart Example 2:
Sum of two numbers

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Flow Chart Example 3:
Whether a number is Prime or Not?

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus

Algorithms
Steps of Programming Practices
• Step1: Requirements

• Step2: Creating a flow chart

• Step3: Creating algorithms

• Step4: Writing Code

• Step5: Debugging

• Step6: Documentation
Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Algorithms

“Algorithms are a way of laying out a problem


independent of the programming language”

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Programming Methodologies
General approach
Top to a Problem Abstract

Approach Approach Approach


to part of to part of to part of
problem problem problem

Specific Specific Specific Specific


steps steps steps steps

Bottom Particular

Algorithms
Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Programming Methodologies
(contd.)
• Design techniques offer mechanisms to create programs that
are easy to understand, free of bugs and convenient to modify.
• If possible, programs should be designed to be reusable.

• Top – Down Programming:


 Reverse engineers the finished products by breaking it into smaller,
manageable or reusable modules.
 Big picture is visualized first before breaking it up into separate
components.

• Bottom – UP Programming:
 Low level components are designed first without fully knowing the big
picture. The components are later integrated to form the complete
system.

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
What is an Algorithm?
 Step by step solution to a problem in English like language.

 It is a finite set of clear and unambiguous steps that must be


followed to solve a computing problem.

 The programmer can convert the algorithm to a program in any


language.

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Programming Logic Constructs
• Imperative statements (Actions)

• Conditional statements (Decision Making)

• Iterative Statements (Repetition / Loops)

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Algorithm Example 1:
Sum of two numbers

1. START
2. Initialize sum=0
3. Input the numbers num1, num2
4. Set sum = num1 + num2.
5. Print sum
6. END

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Algorithm Example 2:
Whether a number is Prime or Not?
1. START
2. Initialize i=2 and p=0.
3. Input the number, gno
4. Check if (gno % i==0) is TRUE then
continue else GOTO step 8
5. Set p=1.
6. Increment value of i.
7. Check if (i<gno) is TRUE then GOTO
step 4.
8. Check if(p==0 or gno=2) then
continue else GOTO step 11.
9. The given number is prime.
10. GOTO step 12.
11. The number is NOT prime.
12. END
Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
Exercise

Roots of Quadratic equation


𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0 has the following roots:
𝐷 = 𝑏 2 − 4𝑎𝑐
If D>0 then
root 1 = −𝑏 + 𝐷/2𝑎
root 2 = −𝑏 − 𝐷/2𝑎

• Draw a flowchart to find roots of the above quadratic equation


• Write an equivalent algorithm for the above flow chart

Dept. of Computer Science & Information Systems, BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus

You might also like