SlideShare a Scribd company logo
Algorithm & Flowchart
21CSC2T411: Programming in C
SIMMI S
Assistant Professor
Department Of Computer Science(UG)
Kristu Jayanti College, Autonomous
(Reaccredited A++ Grade by NAAC with CGPA 3.78/4)
Bengaluru -560077,India
Algorithm
An algorithm is a process or a set of rules required to perform calculations or
some other problem-solving operations especially by a computer.
The formal definition of an algorithm is that it contains the finite set of
instructions which are being carried in a specific order to perform the specific
task.
It is not the complete program or code; it is just a solution (logic) of a problem,
which can be represented either as an informal description using a Flowchart
or Pseudocode.
Simmi S,Department Of Computer Science
Characteristics of an Algorithm
Input: An algorithm has some input values. We can pass 0 or some input value
to an algorithm.
Output: We will get 1 or more output at the end of an algorithm.
Unambiguity: An algorithm should be unambiguous which means that the
instructions in an algorithm should be clear and simple.
Finiteness: An algorithm should have finiteness. Here, finiteness means that
the algorithm should contain a limited number of instructions, i.e., the
instructions should be countable.
Simmi S,Department Of Computer Science
Characteristics of an Algorithm
Effectiveness: An algorithm should be effective as each instruction in an
algorithm affects the overall process.
Language independent: An algorithm must be language-independent
so that the instructions in an algorithm can be implemented in any of
the languages with the same output.
Simmi S,Department Of Computer Science
Dataflow of an Algorithm
Problem: A problem can be a real-world problem or any instance from the
real-world problem for which we need to create a program or the set of
instructions. The set of instructions is known as an algorithm.
Algorithm: An algorithm will be designed for a problem which is a step by step
procedure.
Input: After designing an algorithm, the required and the desired inputs are
provided to the algorithm.
Processing unit: The input will be given to the processing unit, and the
processing unit will produce the desired output.
Output: The output is the outcome or the result of the program.
Simmi S,Department Of Computer Science
Why do we need Algorithms?
Scalability: It helps us to understand the scalability. When we have a big real-
world problem, we need to scale it down into small-small steps to easily
analyse the problem.
Performance: The real-world is not easily broken down into smaller steps. If
the problem can be easily broken into smaller steps means that the problem is
feasible.
Simmi S,Department Of Computer Science
How to write an Algorithm?
There are no well-defined standards for writing algorithms. Rather, it is
problem and resource dependent.
 Algorithms are never written to support a particular programming code.
As we know that all programming languages share basic code constructs like
loops (do, for, while), flow-control (if-else), etc. These common constructs can
be used to write an algorithm.
We write algorithms in a step-by-step manner, but it is not always the case.
 Algorithm writing is a process and is executed after the problem domain is
well-defined.
Simmi S,Department Of Computer Science
How to write an Algorithm?
Step 1: Should always start
Step n:[Last step should always stop]
If statements can be used to check conditions/Check can also be used.
To repeat steps to definite times we can use looping keywords such as for
Simmi S,Department Of Computer Science
Algorithm two add two numbers
Method 1:
Step 1: Start
Step 2:read a,b,result
Step 3:result=a+b
Step 4: display
Step 5:Stop
------------------------------------------------------------------------------------------------------------------------
Method2:
Step 1:Start
Step 2:read a=10 b=20
Step 3: result=a+b
Step 4: Display result
Step 5: Stop
Simmi S,Department Of Computer Science
Algorithm two add two numbers
Method 3:
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: sum←num1+num2
Step 5: Display sum
Step 6: Stop
Simmi S,Department Of Computer Science
Flowchart
What is a Flowchart?
Flowchart is a graphical representation of an algorithm.
 Programmers often use it as a program-planning tool to solve a problem.
It makes use of symbols which are connected among them to indicate the
flow of information and processing.
The process of drawing a flowchart for an algorithm is known as
“flowcharting”.
Simmi S,Department Of Computer Science
Simmi S,Department Of Computer Science
Flowchart Symbols
Guidelines for Developing Flowcharts
These are some points to keep in mind while developing a flowchart −
• Flowchart can have only one start and one stop symbol
• On-page connectors are referenced using numbers.
• Off-page connectors are referenced using alphabets
• General flow of processes is top to bottom or left to right
• Arrows should not cross each other.
Simmi S,Department Of Computer Science
Flowchart to multiply two numbers
Simmi S,Department Of Computer Science
STOP
Simmi S,Department Of Computer Science

More Related Content

Similar to c_algo_flowchart.pdf

Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
MIT,Imphal
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
INAM352782
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
ShaswatSurya
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
Dhanu Srikar
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
Madishetty Prathibha
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
ishan743441
 
CP Handout#1
CP Handout#1CP Handout#1
CP Handout#1
trupti1976
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
NayanChandak1
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
GovindUpadhyay25
 
Software develop....
Software develop.... Software develop....
Software develop....
GCWUS
 
chapter 1
chapter 1chapter 1
chapter 1
yatheesha
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
AnuragJoshi813963
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
Praveen M Jigajinni
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
Saurabh846965
 

Similar to c_algo_flowchart.pdf (20)

Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
CP Handout#1
CP Handout#1CP Handout#1
CP Handout#1
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
 
Software develop....
Software develop.... Software develop....
Software develop....
 
chapter 1
chapter 1chapter 1
chapter 1
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 

More from simmis5

Software reuse is the use of existing artifacts to build new software compone...
Software reuse is the use of existing artifacts to build new software compone...Software reuse is the use of existing artifacts to build new software compone...
Software reuse is the use of existing artifacts to build new software compone...
simmis5
 
Unified Modeling Language in Software Engineering
Unified Modeling Language in Software EngineeringUnified Modeling Language in Software Engineering
Unified Modeling Language in Software Engineering
simmis5
 
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
simmis5
 
The Concept of Abstract Window Took Kit In Java
The Concept of Abstract Window Took Kit In JavaThe Concept of Abstract Window Took Kit In Java
The Concept of Abstract Window Took Kit In Java
simmis5
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
simmis5
 
Software Engineering :Project Management
Software Engineering :Project ManagementSoftware Engineering :Project Management
Software Engineering :Project Management
simmis5
 
The Concept Of Multithreading In Java Programming
The Concept Of Multithreading In Java ProgrammingThe Concept Of Multithreading In Java Programming
The Concept Of Multithreading In Java Programming
simmis5
 
Conditional Statements & Loops
Conditional Statements & LoopsConditional Statements & Loops
Conditional Statements & Loops
simmis5
 
STRING HANDLING FUNCTIONS.pdf
STRING HANDLING FUNCTIONS.pdfSTRING HANDLING FUNCTIONS.pdf
STRING HANDLING FUNCTIONS.pdf
simmis5
 
Multiplexer.pdf
Multiplexer.pdfMultiplexer.pdf
Multiplexer.pdf
simmis5
 
Encoder_decoder_si.pdf
Encoder_decoder_si.pdfEncoder_decoder_si.pdf
Encoder_decoder_si.pdf
simmis5
 

More from simmis5 (11)

Software reuse is the use of existing artifacts to build new software compone...
Software reuse is the use of existing artifacts to build new software compone...Software reuse is the use of existing artifacts to build new software compone...
Software reuse is the use of existing artifacts to build new software compone...
 
Unified Modeling Language in Software Engineering
Unified Modeling Language in Software EngineeringUnified Modeling Language in Software Engineering
Unified Modeling Language in Software Engineering
 
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
JAVA SWING:Swing is a Java Foundation Classes [JFC] library and an extension ...
 
The Concept of Abstract Window Took Kit In Java
The Concept of Abstract Window Took Kit In JavaThe Concept of Abstract Window Took Kit In Java
The Concept of Abstract Window Took Kit In Java
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Software Engineering :Project Management
Software Engineering :Project ManagementSoftware Engineering :Project Management
Software Engineering :Project Management
 
The Concept Of Multithreading In Java Programming
The Concept Of Multithreading In Java ProgrammingThe Concept Of Multithreading In Java Programming
The Concept Of Multithreading In Java Programming
 
Conditional Statements & Loops
Conditional Statements & LoopsConditional Statements & Loops
Conditional Statements & Loops
 
STRING HANDLING FUNCTIONS.pdf
STRING HANDLING FUNCTIONS.pdfSTRING HANDLING FUNCTIONS.pdf
STRING HANDLING FUNCTIONS.pdf
 
Multiplexer.pdf
Multiplexer.pdfMultiplexer.pdf
Multiplexer.pdf
 
Encoder_decoder_si.pdf
Encoder_decoder_si.pdfEncoder_decoder_si.pdf
Encoder_decoder_si.pdf
 

Recently uploaded

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 

Recently uploaded (20)

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 

c_algo_flowchart.pdf

  • 1. Algorithm & Flowchart 21CSC2T411: Programming in C SIMMI S Assistant Professor Department Of Computer Science(UG) Kristu Jayanti College, Autonomous (Reaccredited A++ Grade by NAAC with CGPA 3.78/4) Bengaluru -560077,India
  • 2. Algorithm An algorithm is a process or a set of rules required to perform calculations or some other problem-solving operations especially by a computer. The formal definition of an algorithm is that it contains the finite set of instructions which are being carried in a specific order to perform the specific task. It is not the complete program or code; it is just a solution (logic) of a problem, which can be represented either as an informal description using a Flowchart or Pseudocode. Simmi S,Department Of Computer Science
  • 3. Characteristics of an Algorithm Input: An algorithm has some input values. We can pass 0 or some input value to an algorithm. Output: We will get 1 or more output at the end of an algorithm. Unambiguity: An algorithm should be unambiguous which means that the instructions in an algorithm should be clear and simple. Finiteness: An algorithm should have finiteness. Here, finiteness means that the algorithm should contain a limited number of instructions, i.e., the instructions should be countable. Simmi S,Department Of Computer Science
  • 4. Characteristics of an Algorithm Effectiveness: An algorithm should be effective as each instruction in an algorithm affects the overall process. Language independent: An algorithm must be language-independent so that the instructions in an algorithm can be implemented in any of the languages with the same output. Simmi S,Department Of Computer Science
  • 5. Dataflow of an Algorithm Problem: A problem can be a real-world problem or any instance from the real-world problem for which we need to create a program or the set of instructions. The set of instructions is known as an algorithm. Algorithm: An algorithm will be designed for a problem which is a step by step procedure. Input: After designing an algorithm, the required and the desired inputs are provided to the algorithm. Processing unit: The input will be given to the processing unit, and the processing unit will produce the desired output. Output: The output is the outcome or the result of the program. Simmi S,Department Of Computer Science
  • 6. Why do we need Algorithms? Scalability: It helps us to understand the scalability. When we have a big real- world problem, we need to scale it down into small-small steps to easily analyse the problem. Performance: The real-world is not easily broken down into smaller steps. If the problem can be easily broken into smaller steps means that the problem is feasible. Simmi S,Department Of Computer Science
  • 7. How to write an Algorithm? There are no well-defined standards for writing algorithms. Rather, it is problem and resource dependent.  Algorithms are never written to support a particular programming code. As we know that all programming languages share basic code constructs like loops (do, for, while), flow-control (if-else), etc. These common constructs can be used to write an algorithm. We write algorithms in a step-by-step manner, but it is not always the case.  Algorithm writing is a process and is executed after the problem domain is well-defined. Simmi S,Department Of Computer Science
  • 8. How to write an Algorithm? Step 1: Should always start Step n:[Last step should always stop] If statements can be used to check conditions/Check can also be used. To repeat steps to definite times we can use looping keywords such as for Simmi S,Department Of Computer Science
  • 9. Algorithm two add two numbers Method 1: Step 1: Start Step 2:read a,b,result Step 3:result=a+b Step 4: display Step 5:Stop ------------------------------------------------------------------------------------------------------------------------ Method2: Step 1:Start Step 2:read a=10 b=20 Step 3: result=a+b Step 4: Display result Step 5: Stop Simmi S,Department Of Computer Science
  • 10. Algorithm two add two numbers Method 3: Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values num1 and num2. Step 4: sum←num1+num2 Step 5: Display sum Step 6: Stop Simmi S,Department Of Computer Science
  • 12. What is a Flowchart? Flowchart is a graphical representation of an algorithm.  Programmers often use it as a program-planning tool to solve a problem. It makes use of symbols which are connected among them to indicate the flow of information and processing. The process of drawing a flowchart for an algorithm is known as “flowcharting”. Simmi S,Department Of Computer Science
  • 13. Simmi S,Department Of Computer Science Flowchart Symbols
  • 14. Guidelines for Developing Flowcharts These are some points to keep in mind while developing a flowchart − • Flowchart can have only one start and one stop symbol • On-page connectors are referenced using numbers. • Off-page connectors are referenced using alphabets • General flow of processes is top to bottom or left to right • Arrows should not cross each other. Simmi S,Department Of Computer Science
  • 15. Flowchart to multiply two numbers Simmi S,Department Of Computer Science STOP
  • 16. Simmi S,Department Of Computer Science