SlideShare a Scribd company logo
1 of 15
Algorithm:
An algorithm is a well defined list of steps for solving
a particular problem.
The criteria of an algorithm are:
1. An algorithm takes zero or more input.
2. It produces at least one output. Sum := A + B
3. Each instruction must be clear.
4. If we trace out the instructions of an algorithm, then for
all cases, the algorithm terminates after a finite number
of steps.
5. Each instruction must be very basic so that it can be
carried out.
Read: A, B
add 6 or 7 to x
Write an algorithm to add two integer number
This algorithm takes two number as input and find the
summation of those numbers as output. Suppose the
two numbers A , B and sum is used for carrying out
the summation of these two numbers.
Step 1. Start
Step 2.Read : A, B
Step 3. Sum := A + B
Step 4. Write : sum
Step 5. Exit
Y=A+B; Y=10+11; Y=21
Write an algorithm that is used to convert the given
Fahrenheit temperature to Centigrade temperature.
This algorithm takes temperature in Fahrenheit (F) as
input and convert it to centigrade(C) as output.
Step 1. Start
Step 2. Read: F(Temperature in Fahrenheit)
Step 3.
Step 4. Write: C(Temperature in Centigrade)
Step 5. Exit
9
32)5(FC โˆ’=
9
32)5(F:C โˆ’=
Write an algorithm that will take three number
as input and find average of those number.
Step 1. Start
Step 2. Read: A, B, C
Step 3. Sum := A + B + C
Step 4. Ave:= Sum/3
Step 5. Write: Ave
Step 6. Exit
Write an algorithm to check if a given number is
Even or Odd. (4%2=0, 7%2=1, 8%2=0, 11%2=1)
This algorithm takes one number as input and find if the
number is even or odd. Here Let X = Given Number
Step 1. Start
Step 2. Read: X
Step 3. Y := X%2
Step 4. If Y := 0, Then
Write: Even Number
else
Write: Odd Number
Step 5. Exit
Write an algorithm to solve the following conditions:
1. Pay tax 150 if amount>=11500
2. Pay tax 100 if amount>=8000
3. Otherwise tax=0
In this algorithm we take amount as input and find payable tax as output.
Step 1. Start
Step 2. Read: amount
Step 3. If amount>=11500, then
Tax :=150
else if amount>=8000, then
Tax := 100
else
Tax := 0
Step 4. Write: Tax
Step 5. Exit
Suppose you will get Commission on the basis of your sell. The Criteria for getting
commission is given below:
1. 7% of total sell if Selling amount greater then or equal to 200000.
2. 5% of total sell if Selling amount greater then or equal to 150000.
3. 2% of total sell if Selling amount greater then or equal to 100000.
4. 1% Otherwise.
Step 1. Start
Step 2.Read: amount
Step 3. If amount>=200000, then
Commission :=amount * 7%
else if amount>=150000, then
Commission :=amount * 5%
else if amount>=100000, then
Commission :=amount * 2%
else
Commission :=amount * 1%
Step 4. Write: Commission
write an algorithm that will used to compute the following
after reading a value of X
1. Y=(X2
+ 2X โ€“1)/5 If X<0
2. Y= X โ€“ 3 If X=0
3. Y= X โ€“ 14 If X>0
Step 1. Start
Step 2. Read: X
Step 3. If X<0, then
Y:=(X2
+ 2X โ€“1)/5
else if X=0, then
Y:= X - 3
else
Y:= X โ€“ 14
Step 4. Write: Y
Step 5. Exit
Write an algorithm to solve the following equation:
1+2+3+4+5+โ€ฆโ€ฆโ€ฆ.+N
Step 1. Start
Step 2. Read: N
Step 3. Set K := 1, Sum:= 0
Step 4. Repeat Steps 5 and 6 while K<=N
Step 5. Sum := Sum + K
Step 6. Set K := K + 1
Step 7. Write: Sum
Step 8. Exit
Write an algorithm to solve the following equation:
12
+22
+32
+42
+52
+.......................+N2
Step 1. Start
Step 2. Read: N
Step 3. Set K := 1, Sum:= 0
Step 4. Repeat Steps 5 and 6 while K<=N
Step 5. Sum := Sum + (K*K)
Step 6. Set K := K + 1
Step 7. Write: Sum
Step 8. Exit
Write an algorithm to solve the following equation:
1+3+5+7+.......................+N
Step 1. Start
Step 2. Read: N
Step 3. Set K := 1, Sum:= 0
Step 4. Repeat Steps 5and 6 while K<=N
Step 5. Sum := Sum + K
Step 6. Set K := K + 2
Step 7. Write: Sum
Step 8. Exit
Write an algorithm to find the factorial of a given number.
1*2*3*4*5โ€ฆ..*N=N!
Step 1. Start
Step 2. Read: N
Step 3. Set K := 1, Fact:= 1
Step 4. Repeat Steps 5 and 6 while K<=N
Step 5. Fact:= Fact * K
Step 6. Set K := K + 1
Step 7. Write: Fact
Step 8. Exit
Write an algorithm to calculate the following equation
y=a2
+2ab+b2
Step 1. Start
Step 2. Read: a, b
Step 3. y := a2
+2ab+b2
Step 4. Write: y
Step 5. Exit
Write an algorithm to find result using the following
conditions:
Conditions Result
Marks>=80 A+
Marks>=75 A
Marks>=70 B+
Marks>=65 B
Marks>=60 D
F Otherwise
Step 1. Start
Step 2. Read: Marks
Step 3. If Marks>=80, then
result:=โ€œA+โ€
else if Marks>=75, then
result:=โ€œA-โ€
else if Marks>=70, then
result:=โ€œB+โ€
else if Marks>=65, then
result:=โ€œBโ€
else if Marks>=60, then
result:=โ€œDโ€
else result:=โ€œFโ€
Step 4. Write: result
Step 5. Exit

More Related Content

What's hot (6)

Telling time
Telling timeTelling time
Telling time
ย 
Study tutor
Study tutorStudy tutor
Study tutor
ย 
Significant figures
Significant figuresSignificant figures
Significant figures
ย 
Multiplywholenumber1
Multiplywholenumber1Multiplywholenumber1
Multiplywholenumber1
ย 
Sig Figs
Sig FigsSig Figs
Sig Figs
ย 
Chapter#7
Chapter#7Chapter#7
Chapter#7
ย 

Similar to Algorithm

UNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptxUNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptx
RSathyaPriyaCSEKIOT
ย 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
Saurabh846965
ย 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
rajnidhiman
ย 
Module 1 topic 1 notes
Module 1 topic 1 notesModule 1 topic 1 notes
Module 1 topic 1 notes
Michelle Barnhill
ย 
September 11, 2014
September 11, 2014September 11, 2014
September 11, 2014
khyps13
ย 

Similar to Algorithm (20)

UNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptxUNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptx
ย 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
ย 
Problem solving using Programming
Problem solving using ProgrammingProblem solving using Programming
Problem solving using Programming
ย 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
ย 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
ย 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
ย 
algorithm
algorithmalgorithm
algorithm
ย 
Lesson 3
Lesson 3Lesson 3
Lesson 3
ย 
C language algorithms
C language algorithmsC language algorithms
C language algorithms
ย 
UNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptxUNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptx
ย 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
ย 
Course project solutions 2019
Course project solutions 2019Course project solutions 2019
Course project solutions 2019
ย 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
ย 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
ย 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
ย 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
ย 
Module 1 topic 1 notes
Module 1 topic 1 notesModule 1 topic 1 notes
Module 1 topic 1 notes
ย 
Number system
Number systemNumber system
Number system
ย 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
ย 
September 11, 2014
September 11, 2014September 11, 2014
September 11, 2014
ย 

Recently uploaded

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
ย 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
ย 
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
sivaprakash250
ย 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
ย 

Recently uploaded (20)

Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
ย 
Top Rated Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
ย 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
ย 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
ย 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
ย 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
ย 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
ย 
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
ย 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
ย 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
ย 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
ย 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
ย 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
ย 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
ย 

Algorithm

  • 1. Algorithm: An algorithm is a well defined list of steps for solving a particular problem. The criteria of an algorithm are: 1. An algorithm takes zero or more input. 2. It produces at least one output. Sum := A + B 3. Each instruction must be clear. 4. If we trace out the instructions of an algorithm, then for all cases, the algorithm terminates after a finite number of steps. 5. Each instruction must be very basic so that it can be carried out. Read: A, B add 6 or 7 to x
  • 2. Write an algorithm to add two integer number This algorithm takes two number as input and find the summation of those numbers as output. Suppose the two numbers A , B and sum is used for carrying out the summation of these two numbers. Step 1. Start Step 2.Read : A, B Step 3. Sum := A + B Step 4. Write : sum Step 5. Exit Y=A+B; Y=10+11; Y=21
  • 3. Write an algorithm that is used to convert the given Fahrenheit temperature to Centigrade temperature. This algorithm takes temperature in Fahrenheit (F) as input and convert it to centigrade(C) as output. Step 1. Start Step 2. Read: F(Temperature in Fahrenheit) Step 3. Step 4. Write: C(Temperature in Centigrade) Step 5. Exit 9 32)5(FC โˆ’= 9 32)5(F:C โˆ’=
  • 4. Write an algorithm that will take three number as input and find average of those number. Step 1. Start Step 2. Read: A, B, C Step 3. Sum := A + B + C Step 4. Ave:= Sum/3 Step 5. Write: Ave Step 6. Exit
  • 5. Write an algorithm to check if a given number is Even or Odd. (4%2=0, 7%2=1, 8%2=0, 11%2=1) This algorithm takes one number as input and find if the number is even or odd. Here Let X = Given Number Step 1. Start Step 2. Read: X Step 3. Y := X%2 Step 4. If Y := 0, Then Write: Even Number else Write: Odd Number Step 5. Exit
  • 6. Write an algorithm to solve the following conditions: 1. Pay tax 150 if amount>=11500 2. Pay tax 100 if amount>=8000 3. Otherwise tax=0 In this algorithm we take amount as input and find payable tax as output. Step 1. Start Step 2. Read: amount Step 3. If amount>=11500, then Tax :=150 else if amount>=8000, then Tax := 100 else Tax := 0 Step 4. Write: Tax Step 5. Exit
  • 7. Suppose you will get Commission on the basis of your sell. The Criteria for getting commission is given below: 1. 7% of total sell if Selling amount greater then or equal to 200000. 2. 5% of total sell if Selling amount greater then or equal to 150000. 3. 2% of total sell if Selling amount greater then or equal to 100000. 4. 1% Otherwise. Step 1. Start Step 2.Read: amount Step 3. If amount>=200000, then Commission :=amount * 7% else if amount>=150000, then Commission :=amount * 5% else if amount>=100000, then Commission :=amount * 2% else Commission :=amount * 1% Step 4. Write: Commission
  • 8. write an algorithm that will used to compute the following after reading a value of X 1. Y=(X2 + 2X โ€“1)/5 If X<0 2. Y= X โ€“ 3 If X=0 3. Y= X โ€“ 14 If X>0 Step 1. Start Step 2. Read: X Step 3. If X<0, then Y:=(X2 + 2X โ€“1)/5 else if X=0, then Y:= X - 3 else Y:= X โ€“ 14 Step 4. Write: Y Step 5. Exit
  • 9. Write an algorithm to solve the following equation: 1+2+3+4+5+โ€ฆโ€ฆโ€ฆ.+N Step 1. Start Step 2. Read: N Step 3. Set K := 1, Sum:= 0 Step 4. Repeat Steps 5 and 6 while K<=N Step 5. Sum := Sum + K Step 6. Set K := K + 1 Step 7. Write: Sum Step 8. Exit
  • 10. Write an algorithm to solve the following equation: 12 +22 +32 +42 +52 +.......................+N2 Step 1. Start Step 2. Read: N Step 3. Set K := 1, Sum:= 0 Step 4. Repeat Steps 5 and 6 while K<=N Step 5. Sum := Sum + (K*K) Step 6. Set K := K + 1 Step 7. Write: Sum Step 8. Exit
  • 11. Write an algorithm to solve the following equation: 1+3+5+7+.......................+N Step 1. Start Step 2. Read: N Step 3. Set K := 1, Sum:= 0 Step 4. Repeat Steps 5and 6 while K<=N Step 5. Sum := Sum + K Step 6. Set K := K + 2 Step 7. Write: Sum Step 8. Exit
  • 12. Write an algorithm to find the factorial of a given number. 1*2*3*4*5โ€ฆ..*N=N! Step 1. Start Step 2. Read: N Step 3. Set K := 1, Fact:= 1 Step 4. Repeat Steps 5 and 6 while K<=N Step 5. Fact:= Fact * K Step 6. Set K := K + 1 Step 7. Write: Fact Step 8. Exit
  • 13. Write an algorithm to calculate the following equation y=a2 +2ab+b2 Step 1. Start Step 2. Read: a, b Step 3. y := a2 +2ab+b2 Step 4. Write: y Step 5. Exit
  • 14. Write an algorithm to find result using the following conditions: Conditions Result Marks>=80 A+ Marks>=75 A Marks>=70 B+ Marks>=65 B Marks>=60 D F Otherwise
  • 15. Step 1. Start Step 2. Read: Marks Step 3. If Marks>=80, then result:=โ€œA+โ€ else if Marks>=75, then result:=โ€œA-โ€ else if Marks>=70, then result:=โ€œB+โ€ else if Marks>=65, then result:=โ€œBโ€ else if Marks>=60, then result:=โ€œDโ€ else result:=โ€œFโ€ Step 4. Write: result Step 5. Exit