SlideShare a Scribd company logo
1
Subject : C.P.U
Topic: Algorithms and Flowchart
2
Name of Students in Group:
ALGORITHMS AND
FLOWCHARTS
Program design
 Program Design Process has 2 phases:
 Problem Solving Phase
 Creates an algorithm that solves the
problem
 Implementation (Coding) Phase
 Translates the algorithm into a
programming language
4
Algorithm
Problem Program
Algorithms
 An algorithm is a finite set of steps defining the
solution of a particular problem.
 Need not to belong one particular language
 Sequence of English statements can also be
algorithm
 It is not a computer program
 An algorithm can be expressed in English like
language called pseudo code, in a programming
language or in the form of flowchart.
5
Algorithm Vs Program
 What is the difference between an algorithm and a program?
 a program is an implementation of an algorithm to be run on a
specific computer and operating system.
 an algorithm is more abstract – it does not deal with machine
specific details – think of it as a method to solve a problem.
• What is good algorithm?
Efficient algorithms are good, we generally measure efficiency of an
algorithm on the basis of:
1. Time: algorithm should take minimum time to execute.
2. Space: algorithm should use less memory.
6
Algorithm Specification
Every algorithm must satisfy the following criteria:
 Input. Zero or more quantities are externally supplied.
 Output. At least one quantity is produced.
 Definiteness. Each instruction must be clear and
unambiguous(Unique meaning).
 Finiteness. An algorithm terminates in a finite
number of steps.
 Effectiveness. Every instruction must be basic enough
to be carried out than, means not so complex.
7
8
Informal definition of an algorithm
9
Finding the largest integer
among five integers
10
Defining actions in Find Largest algorithm
11
12
Example 1
Write an algorithm that finds the
average of two numbers
Solution:
Average Of Two
Input: Two numbers
1. Add the two numbers
2. Divide the result by 2
3. Return the result by step 2 2
End
Group 13
Example 2
Write an algorithm to change a numeric
grade to a pass/fail grade.
Solution:
Pass/Fail Grade
Input: One number
1. if (the number is greater than or equal to 40)
then
1.1 Set the grade to “pass”
else
1.2 Set the grade to “fail”
End if
2. Return the grade
End
14
Example 3
Write an algorithm for grading System
by following method.
Marks range Grade
>=80 A
>=70 & <80 B
>=60 & <70 C
>=50 & <60 D
<50 F
15
Algorithm For Grade
Input: One number
1. if (the number is between 80 and 100, inclusive)
then
1.1 Set the grade to “A”
End if
2. if (the number is between 70 and 79, inclusive)
then
2.1 Set the grade to “B”
End if
Algorithm for Grading
Continues on the next slide
Solution
16
3. if (the number is between 60 and 69, inclusive)
then
3.1 Set the grade to “C”
End if
4. if (the number is between 50 and 59, inclusive)
then
4.1 Set the grade to “D”
End if
5. If (the number is less than 50)
then
5.1 Set the grade to “F”
End if
6. Return the grade
End
Advantages Of Algorithm
 It provides the core solution to a given problem. This
solution can be implemented on a computer system
using any programming language of user’s choice.
 It facilitates program development by acting as a
design document or a blueprint of a given problem
solution.
 It ensures easy comprehension of a problem solution
as compared to an equivalent computer program.
 It eases identification and removal of logical errors in
a program.
 It facilitates algorithm analysis to find out the most
efficient solution to a given problem.
17
Disadvantages Of
Algorithm
 In large algorithms, the flow of program control becomes difficult
to track.
 Algorithms lack visual representation of programming constructs
like flowcharts; thus, understanding the logic becomes relatively
difficult.
18
Flowchart
A graphical representation of an algorithm, often
used in the design phase of programming to work
out the logical flow of a program.
 Visual way to represent the information flow
 Make our logic more clear
 Help during writing of program
 Make testing and debugging easy
19
20
Flowchart or program
constructs
 Sequence: The order of execution, this typically refers to
the order in which the code will execute. Normally code
executes line by line, so line 1 then 2 then 3 and so on.
 Selection: Selection, like branching, is a method of
controlling the execution sequence, you can create large
control blocks, using if statements testing a condition, or
switch statements evaluating a variable etc to control and
change the execution of the program depending on this
environment and changing variables.
 Iteration (Repetition): Iteration is typically used to refer to
collections and arrays of variables and data. Repeating set
of instruction. Counting from 1 to 10, you are iterating
over the first 10 numbers. for, while, do-while loops will be
implemented for iteration.
21
Flowchart Constructs
22
Flowchart Constructs
(cont..)
23
24
Flowchart Constructs
(cont..)
Example-1
Write an algorithm and draw a flowchart
that will read the two sides of a
rectangle and calculate its area.
Algorithm
 Step 1: Start
 Step 2: Take Width and Length as input
 Step 3: Calculate Area by Width* Length
 Step 4: Print Area.
 Step 5: End
25
Example-1
 Step 1: Start
 Step 2: Input W,L
 Step 3: A  L x W
 Step 4: Print A
 Step 5: End
26
START
Input
W, L
A L x W
STOP
Print
A
Example-2
 Write an Pseudo code and draw a
flowchart that will take marks of four
subjects and calculate the average.
Then if average marks are greater than
50 then print PASS otherwise print FAIL.
27
Example-2
28
Step 1: Start
Step 2: Input M1,M2,M3,M4
Step 3: AVG 
(M1+M2+M3+M4)/4
Step 4: if (AVG <50) then
Print “FAIL”
else
Print “PASS”
endif
Step 5: End
START
Input
M1,M2,M3,M4
AVG(M1+M2+M3+M4)/4
IS
AVG<50
STOP
YN
Print
“PASS”
Print
“FAIL”
Example-3
 Write an algorithm and draw a
flowchart to convert the length in
feet to centimeter.
29
Example-3
Algorithm
 Step 1: Start
 Step 2: Input Lft
 Step 3: Lcm  Lft x 30
 Step 4: Print Lcm
 Step 5: End
30
START
Input
Lft
Lcm Lft x 30
Print
Lcm
STOP
Flowchart
Example-4
 Write an algorithm and draw a flowchart
that will calculate the roots of a quadratic
equation
 Hint: d = sqrt ( ), and the roots are:
x1 = (–b + d)/2a and x2 = (–b – d)/2a
2
0ax bx c  
2
4b ac
31
Example-4
Algorithm:
 Step 1: Start
 Step 2: Input a, b, c
 Step 3: d  sqrt ( )
 Step 4: x1  (–b + d) / (2 x a)
 Step 5: x2  (–b – d) / (2 x a)
 Step 6: Print x1, x2
 Step 7: End
4b b a c   
32
START
Input
a, b, c
d  sqrt(b x b – 4 x a x c)
Print
x1 ,x2
STOP
x1 (–b + d) / (2 x a)
X2 (–b – d) / (2 x a)
Flow Chart`s Limitation
 For very large program, flow chart goes
for many pages
 Costly to draw flow charts for large
program
 Difficult to modify
33
Algorithm and flowchart

More Related Content

What's hot (20)

Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Introduction to Flowchart
Introduction to FlowchartIntroduction to Flowchart
Introduction to Flowchart
ChristopherEsteban2
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
salmankhan570
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
Dr.Sandhiya Ravi
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
Ibrahimcommunication Al Ani
 
Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)
Project Student
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
Rohit Shrivastava
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
Syed Zaid Irshad
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
Neeru Mittal
 
BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming Language
Jeff Valerio
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
ehsanullah786
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
Anil Kumar
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer
Ashim Lamichhane
 
Coding
CodingCoding
Coding
Vishal Singh
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
salmankhan570
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
Dr.Sandhiya Ravi
 
Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)
Project Student
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
Rohit Shrivastava
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
Neeru Mittal
 
BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming Language
Jeff Valerio
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
ehsanullah786
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
Anil Kumar
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer
Ashim Lamichhane
 

Viewers also liked (20)

Flowcharts
FlowchartsFlowcharts
Flowcharts
Mukesh Tekwani
 
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
vinay arora
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
Sayali Shivarkar
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
Jordan Delacruz
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
IamPe Khamkhum
 
Best Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing TechniquesBest Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing Techniques
Tech
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
Ibrahim Reda
 
Flowchart - Sistem Komputer
Flowchart - Sistem KomputerFlowchart - Sistem Komputer
Flowchart - Sistem Komputer
Andita Eka Wahyuni
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Hüseyin Ergin
 
Makalah Diagram Alur ( FlowChart )
Makalah Diagram Alur ( FlowChart )Makalah Diagram Alur ( FlowChart )
Makalah Diagram Alur ( FlowChart )
Muhammad Iqbal
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
Chong-Kuan Chen
 
Flowchart slides powerpoint
Flowchart slides powerpointFlowchart slides powerpoint
Flowchart slides powerpoint
hilmius akbar
 
3.algoritma dasar
3.algoritma dasar3.algoritma dasar
3.algoritma dasar
Putri Damayanti
 
3 buku pedoman pkl 2016
3 buku pedoman pkl 20163 buku pedoman pkl 2016
3 buku pedoman pkl 2016
Pandu Wiza
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
Anshumali Singh
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
Tareq Hasan
 
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
vinay arora
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
Jordan Delacruz
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
IamPe Khamkhum
 
Best Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing TechniquesBest Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing Techniques
Tech
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
Ibrahim Reda
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Hüseyin Ergin
 
Makalah Diagram Alur ( FlowChart )
Makalah Diagram Alur ( FlowChart )Makalah Diagram Alur ( FlowChart )
Makalah Diagram Alur ( FlowChart )
Muhammad Iqbal
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
Chong-Kuan Chen
 
Flowchart slides powerpoint
Flowchart slides powerpointFlowchart slides powerpoint
Flowchart slides powerpoint
hilmius akbar
 
3 buku pedoman pkl 2016
3 buku pedoman pkl 20163 buku pedoman pkl 2016
3 buku pedoman pkl 2016
Pandu Wiza
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
Ad

Similar to Algorithm and flowchart (20)

Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Kate Campbell
 
UNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year studentsUNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year students
SabarigiriVason
 
ALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdf
meychu1
 
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptLecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
cosc242101003
 
flowchart & algorithms
flowchart & algorithmsflowchart & algorithms
flowchart & algorithms
Student
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
Kirti Verma
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
AnuragJoshi813963
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
dipti reya
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Lesson 1 of c programming algorithms and flowcharts.pptx
Lesson 1 of c programming algorithms and flowcharts.pptxLesson 1 of c programming algorithms and flowcharts.pptx
Lesson 1 of c programming algorithms and flowcharts.pptx
AlinaMishra7
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
AbdelrahmanRagab36
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdf
Guru Nanak Technical Institutions
 
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffdPROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
miansaad18
 
Algorithms-Flowcharts for programming fundamental
Algorithms-Flowcharts for  programming fundamentalAlgorithms-Flowcharts for  programming fundamental
Algorithms-Flowcharts for programming fundamental
fazayn927
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
Dr. Rupinder Singh
 
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
CursedPirate
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
MIT,Imphal
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Kate Campbell
 
UNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year studentsUNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year students
SabarigiriVason
 
ALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdf
meychu1
 
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptLecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
cosc242101003
 
flowchart & algorithms
flowchart & algorithmsflowchart & algorithms
flowchart & algorithms
Student
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
Kirti Verma
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
dipti reya
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Lesson 1 of c programming algorithms and flowcharts.pptx
Lesson 1 of c programming algorithms and flowcharts.pptxLesson 1 of c programming algorithms and flowcharts.pptx
Lesson 1 of c programming algorithms and flowcharts.pptx
AlinaMishra7
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
AbdelrahmanRagab36
 
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffdPROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
miansaad18
 
Algorithms-Flowcharts for programming fundamental
Algorithms-Flowcharts for  programming fundamentalAlgorithms-Flowcharts for  programming fundamental
Algorithms-Flowcharts for programming fundamental
fazayn927
 
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
CursedPirate
 
Ad

Recently uploaded (20)

What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...
cyhuutjdoazdwrnubt
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbbTree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...
ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...
ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...
Journal of Soft Computing in Civil Engineering
 
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
BeHappy728244
 
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghjfHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
yadavshivank2006
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.
Sowndarya6
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
Cloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptxCloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptx
viratkohli82222
 
Environmental Engineering Wastewater.pptx
Environmental Engineering Wastewater.pptxEnvironmental Engineering Wastewater.pptx
Environmental Engineering Wastewater.pptx
SheerazAhmed77
 
Call For Papers - International Journal on Natural Language Computing (IJNLC)
Call For Papers - International Journal on Natural Language Computing (IJNLC)Call For Papers - International Journal on Natural Language Computing (IJNLC)
Call For Papers - International Journal on Natural Language Computing (IJNLC)
kevig
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Journal of Soft Computing in Civil Engineering
 
fy06_46f6-ht30_22_oil_gas_industry_guidelines.ppt
fy06_46f6-ht30_22_oil_gas_industry_guidelines.pptfy06_46f6-ht30_22_oil_gas_industry_guidelines.ppt
fy06_46f6-ht30_22_oil_gas_industry_guidelines.ppt
sukarnoamin
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...
cyhuutjdoazdwrnubt
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbbTree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
BeHappy728244
 
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghjfHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
yadavshivank2006
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.
Sowndarya6
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
Cloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptxCloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptx
viratkohli82222
 
Environmental Engineering Wastewater.pptx
Environmental Engineering Wastewater.pptxEnvironmental Engineering Wastewater.pptx
Environmental Engineering Wastewater.pptx
SheerazAhmed77
 
Call For Papers - International Journal on Natural Language Computing (IJNLC)
Call For Papers - International Journal on Natural Language Computing (IJNLC)Call For Papers - International Journal on Natural Language Computing (IJNLC)
Call For Papers - International Journal on Natural Language Computing (IJNLC)
kevig
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
fy06_46f6-ht30_22_oil_gas_industry_guidelines.ppt
fy06_46f6-ht30_22_oil_gas_industry_guidelines.pptfy06_46f6-ht30_22_oil_gas_industry_guidelines.ppt
fy06_46f6-ht30_22_oil_gas_industry_guidelines.ppt
sukarnoamin
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 

Algorithm and flowchart

  • 1. 1 Subject : C.P.U Topic: Algorithms and Flowchart
  • 2. 2 Name of Students in Group:
  • 4. Program design  Program Design Process has 2 phases:  Problem Solving Phase  Creates an algorithm that solves the problem  Implementation (Coding) Phase  Translates the algorithm into a programming language 4 Algorithm Problem Program
  • 5. Algorithms  An algorithm is a finite set of steps defining the solution of a particular problem.  Need not to belong one particular language  Sequence of English statements can also be algorithm  It is not a computer program  An algorithm can be expressed in English like language called pseudo code, in a programming language or in the form of flowchart. 5
  • 6. Algorithm Vs Program  What is the difference between an algorithm and a program?  a program is an implementation of an algorithm to be run on a specific computer and operating system.  an algorithm is more abstract – it does not deal with machine specific details – think of it as a method to solve a problem. • What is good algorithm? Efficient algorithms are good, we generally measure efficiency of an algorithm on the basis of: 1. Time: algorithm should take minimum time to execute. 2. Space: algorithm should use less memory. 6
  • 7. Algorithm Specification Every algorithm must satisfy the following criteria:  Input. Zero or more quantities are externally supplied.  Output. At least one quantity is produced.  Definiteness. Each instruction must be clear and unambiguous(Unique meaning).  Finiteness. An algorithm terminates in a finite number of steps.  Effectiveness. Every instruction must be basic enough to be carried out than, means not so complex. 7
  • 9. 9 Finding the largest integer among five integers
  • 10. 10 Defining actions in Find Largest algorithm
  • 11. 11
  • 12. 12 Example 1 Write an algorithm that finds the average of two numbers Solution: Average Of Two Input: Two numbers 1. Add the two numbers 2. Divide the result by 2 3. Return the result by step 2 2 End
  • 13. Group 13 Example 2 Write an algorithm to change a numeric grade to a pass/fail grade. Solution: Pass/Fail Grade Input: One number 1. if (the number is greater than or equal to 40) then 1.1 Set the grade to “pass” else 1.2 Set the grade to “fail” End if 2. Return the grade End
  • 14. 14 Example 3 Write an algorithm for grading System by following method. Marks range Grade >=80 A >=70 & <80 B >=60 & <70 C >=50 & <60 D <50 F
  • 15. 15 Algorithm For Grade Input: One number 1. if (the number is between 80 and 100, inclusive) then 1.1 Set the grade to “A” End if 2. if (the number is between 70 and 79, inclusive) then 2.1 Set the grade to “B” End if Algorithm for Grading Continues on the next slide Solution
  • 16. 16 3. if (the number is between 60 and 69, inclusive) then 3.1 Set the grade to “C” End if 4. if (the number is between 50 and 59, inclusive) then 4.1 Set the grade to “D” End if 5. If (the number is less than 50) then 5.1 Set the grade to “F” End if 6. Return the grade End
  • 17. Advantages Of Algorithm  It provides the core solution to a given problem. This solution can be implemented on a computer system using any programming language of user’s choice.  It facilitates program development by acting as a design document or a blueprint of a given problem solution.  It ensures easy comprehension of a problem solution as compared to an equivalent computer program.  It eases identification and removal of logical errors in a program.  It facilitates algorithm analysis to find out the most efficient solution to a given problem. 17
  • 18. Disadvantages Of Algorithm  In large algorithms, the flow of program control becomes difficult to track.  Algorithms lack visual representation of programming constructs like flowcharts; thus, understanding the logic becomes relatively difficult. 18
  • 19. Flowchart A graphical representation of an algorithm, often used in the design phase of programming to work out the logical flow of a program.  Visual way to represent the information flow  Make our logic more clear  Help during writing of program  Make testing and debugging easy 19
  • 20. 20
  • 21. Flowchart or program constructs  Sequence: The order of execution, this typically refers to the order in which the code will execute. Normally code executes line by line, so line 1 then 2 then 3 and so on.  Selection: Selection, like branching, is a method of controlling the execution sequence, you can create large control blocks, using if statements testing a condition, or switch statements evaluating a variable etc to control and change the execution of the program depending on this environment and changing variables.  Iteration (Repetition): Iteration is typically used to refer to collections and arrays of variables and data. Repeating set of instruction. Counting from 1 to 10, you are iterating over the first 10 numbers. for, while, do-while loops will be implemented for iteration. 21
  • 25. Example-1 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Algorithm  Step 1: Start  Step 2: Take Width and Length as input  Step 3: Calculate Area by Width* Length  Step 4: Print Area.  Step 5: End 25
  • 26. Example-1  Step 1: Start  Step 2: Input W,L  Step 3: A  L x W  Step 4: Print A  Step 5: End 26 START Input W, L A L x W STOP Print A
  • 27. Example-2  Write an Pseudo code and draw a flowchart that will take marks of four subjects and calculate the average. Then if average marks are greater than 50 then print PASS otherwise print FAIL. 27
  • 28. Example-2 28 Step 1: Start Step 2: Input M1,M2,M3,M4 Step 3: AVG  (M1+M2+M3+M4)/4 Step 4: if (AVG <50) then Print “FAIL” else Print “PASS” endif Step 5: End START Input M1,M2,M3,M4 AVG(M1+M2+M3+M4)/4 IS AVG<50 STOP YN Print “PASS” Print “FAIL”
  • 29. Example-3  Write an algorithm and draw a flowchart to convert the length in feet to centimeter. 29
  • 30. Example-3 Algorithm  Step 1: Start  Step 2: Input Lft  Step 3: Lcm  Lft x 30  Step 4: Print Lcm  Step 5: End 30 START Input Lft Lcm Lft x 30 Print Lcm STOP Flowchart
  • 31. Example-4  Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation  Hint: d = sqrt ( ), and the roots are: x1 = (–b + d)/2a and x2 = (–b – d)/2a 2 0ax bx c   2 4b ac 31
  • 32. Example-4 Algorithm:  Step 1: Start  Step 2: Input a, b, c  Step 3: d  sqrt ( )  Step 4: x1  (–b + d) / (2 x a)  Step 5: x2  (–b – d) / (2 x a)  Step 6: Print x1, x2  Step 7: End 4b b a c    32 START Input a, b, c d  sqrt(b x b – 4 x a x c) Print x1 ,x2 STOP x1 (–b + d) / (2 x a) X2 (–b – d) / (2 x a)
  • 33. Flow Chart`s Limitation  For very large program, flow chart goes for many pages  Costly to draw flow charts for large program  Difficult to modify 33

Editor's Notes