Algorithm and flowchart

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
1 de 34

Recomendados

Algorithm and flowchart por
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartElizabeth de Leon Aler
87.3K visualizações9 slides
Algorithms and Flowcharts por
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
309.8K visualizações31 slides
Algorithm and flowchart por
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartRabin BK
10.6K visualizações17 slides
Our presentation on algorithm design por
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm designNahid Hasan
22K visualizações23 slides
Algorithm Introduction por
Algorithm IntroductionAlgorithm Introduction
Algorithm IntroductionAshim Lamichhane
10.9K visualizações26 slides
Algorithm por
AlgorithmAlgorithm
AlgorithmIHTISHAM UL HAQ
7.5K visualizações16 slides

Mais conteúdo relacionado

Mais procurados

Unit 1-problem solving with algorithm por
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithmrajkumar1631010038
6.9K visualizações26 slides
Programming Fundamentals por
Programming FundamentalsProgramming Fundamentals
Programming FundamentalsTrivuz ত্রিভুজ
24.7K visualizações42 slides
Introduction to problem solving in C por
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in CDiwakar Pratap Singh 'Deva'
26.9K visualizações23 slides
Introduction to flowchart por
Introduction to flowchartIntroduction to flowchart
Introduction to flowchartJordan Delacruz
70.7K visualizações34 slides
Chapter 6 algorithms and flow charts por
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow chartspraveenjigajinni
8.5K visualizações68 slides
Algorithms Lecture 1: Introduction to Algorithms por
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsBenha University
3.3K visualizações31 slides

Mais procurados(20)

Unit 1-problem solving with algorithm por rajkumar1631010038
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar16310100386.9K visualizações
Introduction to flowchart por Jordan Delacruz
Introduction to flowchartIntroduction to flowchart
Introduction to flowchart
Jordan Delacruz70.7K visualizações
Chapter 6 algorithms and flow charts por praveenjigajinni
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
praveenjigajinni8.5K visualizações
Algorithms Lecture 1: Introduction to Algorithms por Benha University
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Benha University3.3K visualizações
Introduction to programming por Neeru Mittal
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal4.2K visualizações
Algorithm and pseudo codes por hermiraguilar
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
hermiraguilar48.2K visualizações
Variables in C Programming por programming9
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming99K visualizações
Programming Fundamental Presentation por fazli khaliq
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq2.1K visualizações
Algorithms, flow charts and pseudocodes por Satveer Mann
Algorithms, flow charts and pseudocodesAlgorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodes
Satveer Mann372 visualizações
Algorithm and Programming (Introduction of Algorithms) por Adam Mukharil Bachtiar
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar9.9K visualizações
Algorithm and flowchart por Shivam Sharma
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart
Shivam Sharma168 visualizações
Algorithms and flowcharts por Samuel Igbanogu
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
Samuel Igbanogu4.2K visualizações
Pseudocode-Flowchart por lotlot
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
lotlot38.5K visualizações
C tokens por Manu1325
C tokensC tokens
C tokens
Manu132521K visualizações
Theory of programming por tcc_joemarie
Theory of programmingTheory of programming
Theory of programming
tcc_joemarie1K visualizações
Flowchart and algorithem por ehsanullah786
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
ehsanullah7863.3K visualizações
Introduction to c programming por Manoj Tyagi
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Manoj Tyagi4.6K visualizações
Introduction to data structures and Algorithm por Dhaval Kaneria
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria45.6K visualizações

Destaque

3 algorithm-and-flowchart por
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchartRohit Shrivastava
15.1K visualizações37 slides
Flowcharts por
FlowchartsFlowcharts
FlowchartsMukesh Tekwani
23.9K visualizações21 slides
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart por
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchartvinay arora
9K visualizações43 slides
Flowchart and algorithm por
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmSayali Shivarkar
69.8K visualizações10 slides
Algorithm and flowchart2010 por
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010Jordan Delacruz
22.5K visualizações12 slides
Algorithm and flowchart por
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartIamPe Khamkhum
743 visualizações27 slides

Destaque(20)

3 algorithm-and-flowchart por Rohit Shrivastava
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava15.1K visualizações
Flowcharts por Mukesh Tekwani
FlowchartsFlowcharts
Flowcharts
Mukesh Tekwani23.9K visualizações
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart por vinay arora
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
vinay arora9K visualizações
Flowchart and algorithm por Sayali Shivarkar
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
Sayali Shivarkar69.8K visualizações
Algorithm and flowchart2010 por Jordan Delacruz
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
Jordan Delacruz22.5K visualizações
Algorithm and flowchart por IamPe Khamkhum
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
IamPe Khamkhum743 visualizações
C lects (3) por Mongoo Dashjav
C lects (3)C lects (3)
C lects (3)
Mongoo Dashjav697 visualizações
Best Techniques To Design Programs - Program Designing Techniques por Tech
Best Techniques To Design Programs - Program Designing TechniquesBest Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing Techniques
Tech849 visualizações
Microcontroller lec 3 por Ibrahim Reda
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
Ibrahim Reda373 visualizações
Flowchart - Sistem Komputer por Andita Eka Wahyuni
Flowchart - Sistem KomputerFlowchart - Sistem Komputer
Flowchart - Sistem Komputer
Andita Eka Wahyuni2.4K visualizações
Object oriented programming por Hüseyin Ergin
Object oriented programmingObject oriented programming
Object oriented programming
Hüseyin Ergin488 visualizações
Makalah Diagram Alur ( FlowChart ) por Muhammad Iqbal
Makalah Diagram Alur ( FlowChart )Makalah Diagram Alur ( FlowChart )
Makalah Diagram Alur ( FlowChart )
Muhammad Iqbal3.3K visualizações
Compilation and Execution por Chong-Kuan Chen
Compilation and ExecutionCompilation and Execution
Compilation and Execution
Chong-Kuan Chen1.2K visualizações
Ebooks Flow Chart por ALATechSource
Ebooks Flow ChartEbooks Flow Chart
Ebooks Flow Chart
ALATechSource1.5K visualizações
Flowchart slides powerpoint por hilmius akbar
Flowchart slides powerpointFlowchart slides powerpoint
Flowchart slides powerpoint
hilmius akbar1.1K visualizações
3.algoritma dasar por Putri Damayanti
3.algoritma dasar3.algoritma dasar
3.algoritma dasar
Putri Damayanti1.4K visualizações
3 buku pedoman pkl 2016 por Pandu Wiza
3 buku pedoman pkl 20163 buku pedoman pkl 2016
3 buku pedoman pkl 2016
Pandu Wiza3.6K visualizações
C Programming : Arrays por Gagan Deep
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep9K visualizações
Lecture 4 por Anshumali Singh
Lecture 4Lecture 4
Lecture 4
Anshumali Singh11.6K visualizações

Similar a Algorithm and flowchart

UNIT 1.pptx por
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptxShaswatSurya
144 visualizações94 slides
Ch1 principles of software development por
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
2K visualizações35 slides
algorithms and flow chart overview.pdf por
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfAmanPratik11
186 visualizações29 slides
Algorithms and Flowchart.ppt por
Algorithms and Flowchart.pptAlgorithms and Flowchart.ppt
Algorithms and Flowchart.pptMsKGowriDhilipkumar
231 visualizações26 slides
Algorithm and flowchart.pptx por
Algorithm and flowchart.pptxAlgorithm and flowchart.pptx
Algorithm and flowchart.pptxMaheShiva
483 visualizações18 slides
lecture 5 por
 lecture 5 lecture 5
lecture 5umardanjumamaiwada
191 visualizações25 slides

Similar a Algorithm and flowchart(20)

UNIT 1.pptx por ShaswatSurya
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
ShaswatSurya144 visualizações
Ch1 principles of software development por Hattori Sidek
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
Hattori Sidek2K visualizações
algorithms and flow chart overview.pdf por AmanPratik11
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdf
AmanPratik11186 visualizações
Algorithms and Flowchart.ppt por MsKGowriDhilipkumar
Algorithms and Flowchart.pptAlgorithms and Flowchart.ppt
Algorithms and Flowchart.ppt
MsKGowriDhilipkumar231 visualizações
Algorithm and flowchart.pptx por MaheShiva
Algorithm and flowchart.pptxAlgorithm and flowchart.pptx
Algorithm and flowchart.pptx
MaheShiva483 visualizações
Introduction to computer science por umardanjumamaiwada
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
umardanjumamaiwada86 visualizações
AlgorithmAndFlowChart.pdf por SusieMaestre1
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
SusieMaestre1111 visualizações
Chap6 por artipradhan
Chap6Chap6
Chap6
artipradhan2.7K visualizações
Algorithms notes 2 tutorials duniya por TutorialsDuniya.com
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com123 visualizações
Algorithms and flowcharts por khair20
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
khair203.4K visualizações
c_algo_flowchart.pdf por simmis5
c_algo_flowchart.pdfc_algo_flowchart.pdf
c_algo_flowchart.pdf
simmis57 visualizações
Module 1 python.pptx por AnuragJoshi813963
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
AnuragJoshi81396329 visualizações
Unit 1 python (2021 r) por praveena p
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
praveena p525 visualizações
256958.ppt por Bimlesh7
256958.ppt256958.ppt
256958.ppt
Bimlesh729 visualizações
What is algorithm por mshoaib15
What is algorithmWhat is algorithm
What is algorithm
mshoaib1580 visualizações
Software develop.... por GCWUS
Software develop.... Software develop....
Software develop....
GCWUS412 visualizações
AOA Week 01.ppt por INAM352782
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
INAM3527823 visualizações

Último

2_DVD_ASIC_Design_FLow.pdf por
2_DVD_ASIC_Design_FLow.pdf2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdfUsha Mehta
14 visualizações24 slides
Wire Rope por
Wire RopeWire Rope
Wire RopeIwiss Tools Co.,Ltd
8 visualizações5 slides
MSA Website Slideshow (16).pdf por
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdfmsaucla
39 visualizações8 slides
SNMPx por
SNMPxSNMPx
SNMPxAmatullahbutt
12 visualizações12 slides
Dynamics of Hard-Magnetic Soft Materials por
Dynamics of Hard-Magnetic Soft MaterialsDynamics of Hard-Magnetic Soft Materials
Dynamics of Hard-Magnetic Soft MaterialsShivendra Nandan
13 visualizações32 slides
Solar PV por
Solar PVSolar PV
Solar PVIwiss Tools Co.,Ltd
12 visualizações4 slides

Último(20)

2_DVD_ASIC_Design_FLow.pdf por Usha Mehta
2_DVD_ASIC_Design_FLow.pdf2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdf
Usha Mehta14 visualizações
MSA Website Slideshow (16).pdf por msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msaucla39 visualizações
SNMPx por Amatullahbutt
SNMPxSNMPx
SNMPx
Amatullahbutt12 visualizações
Dynamics of Hard-Magnetic Soft Materials por Shivendra Nandan
Dynamics of Hard-Magnetic Soft MaterialsDynamics of Hard-Magnetic Soft Materials
Dynamics of Hard-Magnetic Soft Materials
Shivendra Nandan13 visualizações
Machine Element II Course outline.pdf por odatadese1
Machine Element II Course outline.pdfMachine Element II Course outline.pdf
Machine Element II Course outline.pdf
odatadese16 visualizações
SPICE PARK DEC2023 (6,625 SPICE Models) por Tsuyoshi Horigome
SPICE PARK DEC2023 (6,625 SPICE Models) SPICE PARK DEC2023 (6,625 SPICE Models)
SPICE PARK DEC2023 (6,625 SPICE Models)
Tsuyoshi Horigome14 visualizações
NEW SUPPLIERS SUPPLIES (copie).pdf por georgesradjou
NEW SUPPLIERS SUPPLIES (copie).pdfNEW SUPPLIERS SUPPLIES (copie).pdf
NEW SUPPLIERS SUPPLIES (copie).pdf
georgesradjou7 visualizações
An approach of ontology and knowledge base for railway maintenance por IJECEIAES
An approach of ontology and knowledge base for railway maintenanceAn approach of ontology and knowledge base for railway maintenance
An approach of ontology and knowledge base for railway maintenance
IJECEIAES12 visualizações
SWM L15-L28_drhasan (Part 2).pdf por MahmudHasan747870
SWM L15-L28_drhasan (Part 2).pdfSWM L15-L28_drhasan (Part 2).pdf
SWM L15-L28_drhasan (Part 2).pdf
MahmudHasan74787028 visualizações
Investor Presentation por eser sevinç
Investor PresentationInvestor Presentation
Investor Presentation
eser sevinç16 visualizações
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx por AnnieRachelJohn
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptxSTUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
AnnieRachelJohn25 visualizações
Extensions of Time - Contract Management por brainquisitive
Extensions of Time - Contract ManagementExtensions of Time - Contract Management
Extensions of Time - Contract Management
brainquisitive15 visualizações
Saikat Chakraborty Java Oracle Certificate.pdf por SaikatChakraborty787148
Saikat Chakraborty Java Oracle Certificate.pdfSaikat Chakraborty Java Oracle Certificate.pdf
Saikat Chakraborty Java Oracle Certificate.pdf
SaikatChakraborty78714813 visualizações
Thermal aware task assignment for multicore processors using genetic algorithm por IJECEIAES
Thermal aware task assignment for multicore processors using genetic algorithm Thermal aware task assignment for multicore processors using genetic algorithm
Thermal aware task assignment for multicore processors using genetic algorithm
IJECEIAES29 visualizações
Art of Writing Research article slide share.pptx por sureshc91
Art of Writing Research article slide share.pptxArt of Writing Research article slide share.pptx
Art of Writing Research article slide share.pptx
sureshc9114 visualizações

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

Notas do Editor

  1. 5