SlideShare a Scribd company logo
Problem Solving
Dr. Kuppusamy .P
Associate Professor / SCOPE
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
• Let’s consider two glasses denoted A and B with 30 ml
mango juice and 50 ml orange juice. Find out the way to
exchange the juice in A and B.
Dr. Kuppusamy P
• Declare variables
• Initialize the values
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Move Glass A value 30 to Glass
Temp
Move Glass B value 50 to
Glass A
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Move Glass Temp value 30 to
Glass B
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B and one more variable temp
Step 3. Read the positive numbers to A and B
Step 3. temp ← A
Step 4. A ← B
Step 5. B ← temp
Step 6. Display interchanged numbers in A , B
Step 7. Stop
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B and one more variable temp
Step 3. Read the positive numbers to A and B
Step 3. temp ← A
Step 4. A ← B
Step 5. B ← temp
Step 6. Display interchanged numbers in A , B
Step 7. Stop
Read the positive
numbers to A and B
temp ← A
A ← B
B ← temp
Display
interchanged
numbers in A , B
Stop
Start
Declare variables A, B,
temp
Dr. Kuppusamy P
Problem Statement 2: Design an algorithm
and draw the flow chart to exchange two
values without using temporary variable.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B
Step 3. Read the positive numbers as A and B
Step 3. A ← A + B
Step 4. B ← A - B
Step 5. A ← A - B
Step 6. Display interchanged numbers in A , B
Step 7. Stop
E.g. A = 7, B= 5
A = 7 + 5 =12
B = 12-5 =7
A= 12 - 7 =5
Dr. Kuppusamy P
Problem Statement 2: Design an algorithm
and draw the flow chart to exchange two
values without using temporary variable.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B
Step 3. Read the positive numbers as A and B
Step 3. A ← A + B
Step 4. B ← A - B
Step 5. A ← A - B
Step 6. Display interchanged numbers in A , B
Step 7. Stop
E.g. A = 7, B= 5
A = 7 + 5 =12
B = 12-5 =7
A= 12 - 7 =5
Read the positive
numbers to A and B
A ← A + B
B ← A - B
A ← A - B
Display
interchanged
numbers in A , B
Stop
Start
Declare variables A, B
Dr. Kuppusamy P
Problem Statement 3: Design an algorithm and draw
the flow chart to find the sum of individual digits for
the given non negative integer.
Step 1. Start
Step 2. Declare variable n
Step 3. Read non negative integer (n)
Step 4. Initialize result ← 0
Step 5. Repeat until n > 0
Step 5.1 result ← result + (n % 10)
Step 5.2 n ← n / 10
Step 6. Display result
Step 7. Stop
E.g. Iteration: 1
n = 76
result = 0 + (76 % 10)
n = 76/10
Iteration: 2
n = 7
result = 6 + (7 % 10)
n = 7/10
Dr. Kuppusamy P
Repeat
Yes No
Problem Statement 3: Design an algorithm and draw
the flow chart to find the sum of individual digits for
the given non negative integer.
Step 1. Start
Step 2. Declare variable n
Step 3. Read non negative integer (n)
Step 4. Initialize result ← 0
Step 5. Repeat until n > 0
Step 5.1 result ← result + (n % 10)
Step 5.2 n ← n / 10
Step 6. Display result
Step 7. Stop
Read the positive
number n
result ← result + (n % 10)
n ← n / 10
Display the result
Stop
Start
Declare variable n
Repeat until n >0
Dr. Kuppusamy P
Problem Statement 4: Design an algorithm and draw
the flow chart to find the sum of given set of n positive
integer.
Step 1. Start
Step 2. Declare variables n, sum, a, i
Step 3. Read total numbers value (n) and ‘n’ positive integers in array ‘a’
Step 4. Initialize sum ← 0 , i ← 0
Step 5. Repeat until i < n
Step 5.1 sum ← sum + a[i]
Step 5.2 i ← i + 1
Step 6. Display sum
Step 7. Stop
n = 3
a[] = {2, 3, 4}
sum = 0 , i=0
Iteration: 1
sum = 0 + 2
i = i +1
Iteration: 2
sum = 2 + 3
i = i +1
Iteration: 3
sum = 5 + 4
i = i +1
Dr. Kuppusamy P
Problem Statement 4: Design an algorithm and draw
the flow chart to find the sum of given set of n positive
integer.
Step 1. Start
Step 2. Declare variables n, sum, a
Step 3. Read total numbers value (n)
and ‘n’ positive integers in
array ‘a’
Step 4. Initialize sum ← 0, i ← 0,
Step 5. Repeat until i < n
Step 5.1 sum ← sum + a[i]
Step 5.2 i ← i + 1
Step 6. Display sum
Step 7. Stop
Repeat
Yes No
Read total numbers value (n)
and ‘n’ integers in array ‘a’
sum ← sum + a[i]
i ← i + 1
Display the sum
Stop
Start
Declare variable n, sum, a
Repeat until i <n
Dr. Kuppusamy P
Problem Statement 5: Design an algorithm and draw
the flow chart to find the number of digits in given
number
Sample Input 1: 4582
Sample Output 1: The number of digits in 4582 is 4
Algorithm
Step 1. Start
Step 2. Declare variables
Step 3. Read the input
Step 4. Initialize count ← 0
Step 4. Repeat until n !=0
Step 5.1 count ← count + 1
Step 5.2 n ← n / 10
Step 6. Display count
Step 7. End
Iteration: 1
count = 0 + 1
n= 4582 /10
Iteration: 2
count = 1 + 1
n= 458 /10
Iteration: 3
count = 2 + 1
n= 45 /10
Iteration: 4
count = 3 + 1
n= 4 /10
Iteration: 5
n != 0 → False
Dr. Kuppusamy P
Problem Statement 6: Design an algorithm and draw
the flow chart to find Factorial computation
of given number
Sample Input 1: 4!
Sample Output 1: 24
Step 1. Begin
Step 2. Declare variables
Step 3. Read the decimal number n
Step 4. Initialize fact ← 1, i ← 1
Step 4. if (n != 0)
Step 4.1. Repeat until 1 to n
Step 4.1.1 fact ← fact * i
Step 4.1.2 increment i
Step 5. Display fact
Step 7. End
Iteration: 1
fact = 1 * 1
i = i +1
Iteration: 2
fact = 1 * 2
i = i +1
Iteration: 3
fact = 2 *3
i = i +1
Iteration: 4
fact = 6 * 4
i = i +1
Iteration: 5
i < =n → False
Dr. Kuppusamy P
Problem Statement 7: Design an algorithm and draw
the flow chart to find Sine function computation
Step 1. Begin.
Step 2. Read the input x and n
Step 3. Convert x value to radius using rad ← 3.14/180*x.
Step 4. Initialize sum ← rad, sign ← -1.
Step 5. Repeat for i ← 3 to n in increment by 2.
Step 5.1 power ← pow(rad, i).
Step 5.2 factorial ← factorial*(i-1)*i.
Step 5.3 result ← power / factorial.
Step 5.4 sum ← sum + (sign * result).
Step 5.5 k ← k*(-1).
Step 6. Display the sum as sine series result.
Step 7. End.
Dr. Kuppusamy P
Repeat
Yes No
Read the input x and n
power ← pow(rad, i).
factorial ← factorial*(i-1)*i.
result ← power / factorial.
sum ← sum + (sign * result).
k ← k*(-1)
Display the sum
Stop
Start
Declare variable
Repeat until i <n
Initialize sum, sign
Problem Statement 8: Design an algorithm and draw
the flow chart to generate Fibonacci sequence
Step 1. Begin
Step 2. Get Non-negative decimal limit n
Step 3. Initialize num1 ← 0, num2 ← 1
Step 4. Display num1 and num2
Step 5. Repeat until 1 to n- 2
Step 5.1 num3 ← num1 + num2
Step 5.2 Display num3
Step 5.3 num1 ← num2
Step 5.4 num2 ← num3
Step 6. End
Dr. Kuppusamy P
Input : 5
Output: 0, 1, 1, 2, 3, 5
Problem Statement 9: Design an algorithm and draw
the flow chart to Reverse the digits of an integer
Step 1. Begin
Step 2. Get Non-negative integer num
Step 3. Initialize reversed ← 0
Step 4. Repeat until num > 0
Step 4.1 digit ← n % 10
Step 4.2 reversed ← (reversed * 10) + digit;
Step 4.3 num ← num / 10
Step 5. Display reversed
Step 6. End
Dr. Kuppusamy P
Input : 598
Output: 895
Problem Statement 10: Design an algorithm and draw the flow chart to
Decimal to Binary conversion
Step 1. Begin
Step 2. Get a Positive decimal number (n)
Step 3. Initialize result as null
Step 4. if (n > 1)
Step 4.1. Repeat until n < 2
Step 4.1.1 Remainder ← n % 2
Step 4.1.2 Append remainder with result
Step 4.1.3 n ← n / 2
Step 5. Append n with result
Step 6. Display the reverse of result
Step 7. End
Dr. Kuppusamy P
Input : 3
Output: 011
Repeat
Yes No
Read integer n
Remainder ← n % 2
Append remainder with result
n ← n / 2
Append n with result
Display the reverse of
result
Stop
Start
Declare variable
Initialize result as null
Repeat until n<2
References
Dr. Kuppusamy P
• Herbert Schildt, “Java: The Complete Reference”, McGraw-Hill Education, Tenth
edition, 2017.
• https://www.sitesbay.com
Ad

More Related Content

What's hot (15)

Section 1.2 Quadratic Equations
Section 1.2 Quadratic EquationsSection 1.2 Quadratic Equations
Section 1.2 Quadratic Equations
bgb02burns
 
Class 10 physical science question answer
Class 10 physical science question answerClass 10 physical science question answer
Class 10 physical science question answer
sagnikchoudhury
 
Rational expressions
Rational expressionsRational expressions
Rational expressions
Leslie Amoguis
 
rational equation transformable to quadratic equation.pptx
rational equation transformable to quadratic equation.pptxrational equation transformable to quadratic equation.pptx
rational equation transformable to quadratic equation.pptx
RizaCatli2
 
Mathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic Formula
Mathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic FormulaMathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic Formula
Mathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic Formula
Juan Miguel Palero
 
Solving Quadratic Equations by Factoring
Solving Quadratic Equations by FactoringSolving Quadratic Equations by Factoring
Solving Quadratic Equations by Factoring
Mid Michigan Community College
 
Solving Quadratic Equations
Solving Quadratic EquationsSolving Quadratic Equations
Solving Quadratic Equations
Cipriano De Leon
 
1631 the binomial theorem
1631 the binomial theorem1631 the binomial theorem
1631 the binomial theorem
Dr Fereidoun Dejahang
 
Polynomials(10th) Simplified
Polynomials(10th) SimplifiedPolynomials(10th) Simplified
Polynomials(10th) Simplified
Sajeel Khan
 
Mathematical Induction
Mathematical InductionMathematical Induction
Mathematical Induction
Edelyn Cagas
 
extreme value theorem.pptx
extreme value theorem.pptxextreme value theorem.pptx
extreme value theorem.pptx
GhezelLorenzo1
 
Solución de ecuaciones no lineales
Solución de ecuaciones no linealesSolución de ecuaciones no lineales
Solución de ecuaciones no lineales
SistemadeEstudiosMed
 
Post partum hgre
Post partum hgrePost partum hgre
Post partum hgre
reham ettesh
 
Chinese remainder theorem -new.ppt
Chinese remainder theorem -new.pptChinese remainder theorem -new.ppt
Chinese remainder theorem -new.ppt
ArchanaT30
 
Area between curves
Area between curvesArea between curves
Area between curves
jnaveena j
 
Section 1.2 Quadratic Equations
Section 1.2 Quadratic EquationsSection 1.2 Quadratic Equations
Section 1.2 Quadratic Equations
bgb02burns
 
Class 10 physical science question answer
Class 10 physical science question answerClass 10 physical science question answer
Class 10 physical science question answer
sagnikchoudhury
 
rational equation transformable to quadratic equation.pptx
rational equation transformable to quadratic equation.pptxrational equation transformable to quadratic equation.pptx
rational equation transformable to quadratic equation.pptx
RizaCatli2
 
Mathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic Formula
Mathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic FormulaMathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic Formula
Mathematics 9 Lesson 1-B: Solving Quadratic Equations using Quadratic Formula
Juan Miguel Palero
 
Solving Quadratic Equations
Solving Quadratic EquationsSolving Quadratic Equations
Solving Quadratic Equations
Cipriano De Leon
 
Polynomials(10th) Simplified
Polynomials(10th) SimplifiedPolynomials(10th) Simplified
Polynomials(10th) Simplified
Sajeel Khan
 
Mathematical Induction
Mathematical InductionMathematical Induction
Mathematical Induction
Edelyn Cagas
 
extreme value theorem.pptx
extreme value theorem.pptxextreme value theorem.pptx
extreme value theorem.pptx
GhezelLorenzo1
 
Solución de ecuaciones no lineales
Solución de ecuaciones no linealesSolución de ecuaciones no lineales
Solución de ecuaciones no lineales
SistemadeEstudiosMed
 
Chinese remainder theorem -new.ppt
Chinese remainder theorem -new.pptChinese remainder theorem -new.ppt
Chinese remainder theorem -new.ppt
ArchanaT30
 
Area between curves
Area between curvesArea between curves
Area between curves
jnaveena j
 

Similar to Problem solving using Programming (20)

UNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptxUNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptx
Pradeepkumar964266
 
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2oalgorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
3107aloksingh
 
L- 14. 0 Algorithm_Flowchart_Example.pdf
L- 14. 0 Algorithm_Flowchart_Example.pdfL- 14. 0 Algorithm_Flowchart_Example.pdf
L- 14. 0 Algorithm_Flowchart_Example.pdf
TonmoyIslam16
 
Algorithm
AlgorithmAlgorithm
Algorithm
Md Angkon
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
Arul Jothi Yuvaraja
 
Two step equations
Two step equationsTwo step equations
Two step equations
devsmith07
 
Chapter2.8
Chapter2.8Chapter2.8
Chapter2.8
nglaze10
 
Algorithmsandflowcharts2
Algorithmsandflowcharts2Algorithmsandflowcharts2
Algorithmsandflowcharts2
Darlene Interno
 
5th_NS_1.3_add_and_subtract_integers (3).ppt
5th_NS_1.3_add_and_subtract_integers (3).ppt5th_NS_1.3_add_and_subtract_integers (3).ppt
5th_NS_1.3_add_and_subtract_integers (3).ppt
enasabdulrahman
 
5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt
VGAspirin1
 
5th_NS_1.3_add_and_subtract_integers (1).ppt
5th_NS_1.3_add_and_subtract_integers (1).ppt5th_NS_1.3_add_and_subtract_integers (1).ppt
5th_NS_1.3_add_and_subtract_integers (1).ppt
ShefaCapuras1
 
5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt
AreejAhmed38
 
Computer basics
Computer basicsComputer basics
Computer basics
Kailas Sree Chandran
 
New ways of multiplying numbers
New ways of multiplying numbersNew ways of multiplying numbers
New ways of multiplying numbers
iosrjce
 
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
kamesh dagia
 
PSP LAB MANUAL.pdf
PSP LAB MANUAL.pdfPSP LAB MANUAL.pdf
PSP LAB MANUAL.pdf
Selvaraj Seerangan
 
5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt
sriemisusanti
 
4. algorithm
4. algorithm4. algorithm
4. algorithm
SHIKHA GAUTAM
 
Module 1 topic 1 notes
Module 1 topic 1 notesModule 1 topic 1 notes
Module 1 topic 1 notes
Michelle Barnhill
 
Multiplying Decimals
Multiplying DecimalsMultiplying Decimals
Multiplying Decimals
Lea Perez
 
UNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptxUNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptx
Pradeepkumar964266
 
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2oalgorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
algorithm_practice.pptzkkxiqdhiwdowhdohwod2hodh2odh2o
3107aloksingh
 
L- 14. 0 Algorithm_Flowchart_Example.pdf
L- 14. 0 Algorithm_Flowchart_Example.pdfL- 14. 0 Algorithm_Flowchart_Example.pdf
L- 14. 0 Algorithm_Flowchart_Example.pdf
TonmoyIslam16
 
Two step equations
Two step equationsTwo step equations
Two step equations
devsmith07
 
Chapter2.8
Chapter2.8Chapter2.8
Chapter2.8
nglaze10
 
Algorithmsandflowcharts2
Algorithmsandflowcharts2Algorithmsandflowcharts2
Algorithmsandflowcharts2
Darlene Interno
 
5th_NS_1.3_add_and_subtract_integers (3).ppt
5th_NS_1.3_add_and_subtract_integers (3).ppt5th_NS_1.3_add_and_subtract_integers (3).ppt
5th_NS_1.3_add_and_subtract_integers (3).ppt
enasabdulrahman
 
5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt
VGAspirin1
 
5th_NS_1.3_add_and_subtract_integers (1).ppt
5th_NS_1.3_add_and_subtract_integers (1).ppt5th_NS_1.3_add_and_subtract_integers (1).ppt
5th_NS_1.3_add_and_subtract_integers (1).ppt
ShefaCapuras1
 
5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt
AreejAhmed38
 
New ways of multiplying numbers
New ways of multiplying numbersNew ways of multiplying numbers
New ways of multiplying numbers
iosrjce
 
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
kamesh dagia
 
5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt5th_NS_1.3_add_and_subtract_integers.ppt
5th_NS_1.3_add_and_subtract_integers.ppt
sriemisusanti
 
Multiplying Decimals
Multiplying DecimalsMultiplying Decimals
Multiplying Decimals
Lea Perez
 
Ad

More from Kuppusamy P (20)

Recurrent neural networks rnn
Recurrent neural networks   rnnRecurrent neural networks   rnn
Recurrent neural networks rnn
Kuppusamy P
 
Deep learning
Deep learningDeep learning
Deep learning
Kuppusamy P
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
Kuppusamy P
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
Kuppusamy P
 
Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
Kuppusamy P
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
Kuppusamy P
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithms
Kuppusamy P
 
Algorithm basics
Algorithm basicsAlgorithm basics
Algorithm basics
Kuppusamy P
 
Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software
Kuppusamy P
 
Strings in java
Strings in javaStrings in java
Strings in java
Kuppusamy P
 
Java methods or Subroutines or Functions
Java methods or Subroutines or FunctionsJava methods or Subroutines or Functions
Java methods or Subroutines or Functions
Kuppusamy P
 
Java arrays
Java arraysJava arrays
Java arrays
Kuppusamy P
 
Java iterative statements
Java iterative statementsJava iterative statements
Java iterative statements
Kuppusamy P
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
Kuppusamy P
 
Java data types
Java data typesJava data types
Java data types
Kuppusamy P
 
Java introduction
Java introductionJava introduction
Java introduction
Kuppusamy P
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Anomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningAnomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine Learning
Kuppusamy P
 
Machine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationMachine Learning Performance metrics for classification
Machine Learning Performance metrics for classification
Kuppusamy P
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
Kuppusamy P
 
Recurrent neural networks rnn
Recurrent neural networks   rnnRecurrent neural networks   rnn
Recurrent neural networks rnn
Kuppusamy P
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
Kuppusamy P
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
Kuppusamy P
 
Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
Kuppusamy P
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
Kuppusamy P
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithms
Kuppusamy P
 
Algorithm basics
Algorithm basicsAlgorithm basics
Algorithm basics
Kuppusamy P
 
Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software
Kuppusamy P
 
Java methods or Subroutines or Functions
Java methods or Subroutines or FunctionsJava methods or Subroutines or Functions
Java methods or Subroutines or Functions
Kuppusamy P
 
Java iterative statements
Java iterative statementsJava iterative statements
Java iterative statements
Kuppusamy P
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
Kuppusamy P
 
Java introduction
Java introductionJava introduction
Java introduction
Kuppusamy P
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Anomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningAnomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine Learning
Kuppusamy P
 
Machine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationMachine Learning Performance metrics for classification
Machine Learning Performance metrics for classification
Kuppusamy P
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
Kuppusamy P
 
Ad

Recently uploaded (20)

pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
National Information Standards Organization (NISO)
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 

Problem solving using Programming

  • 1. Problem Solving Dr. Kuppusamy .P Associate Professor / SCOPE Dr. Kuppusamy P
  • 2. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. • Let’s consider two glasses denoted A and B with 30 ml mango juice and 50 ml orange juice. Find out the way to exchange the juice in A and B. Dr. Kuppusamy P
  • 3. • Declare variables • Initialize the values Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Dr. Kuppusamy P
  • 4. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Move Glass A value 30 to Glass Temp Move Glass B value 50 to Glass A Dr. Kuppusamy P
  • 5. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Move Glass Temp value 30 to Glass B Dr. Kuppusamy P
  • 6. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Algorithm Step 1. Start Step 2. Declare two variables A, B and one more variable temp Step 3. Read the positive numbers to A and B Step 3. temp ← A Step 4. A ← B Step 5. B ← temp Step 6. Display interchanged numbers in A , B Step 7. Stop Dr. Kuppusamy P
  • 7. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Algorithm Step 1. Start Step 2. Declare two variables A, B and one more variable temp Step 3. Read the positive numbers to A and B Step 3. temp ← A Step 4. A ← B Step 5. B ← temp Step 6. Display interchanged numbers in A , B Step 7. Stop Read the positive numbers to A and B temp ← A A ← B B ← temp Display interchanged numbers in A , B Stop Start Declare variables A, B, temp Dr. Kuppusamy P
  • 8. Problem Statement 2: Design an algorithm and draw the flow chart to exchange two values without using temporary variable. Algorithm Step 1. Start Step 2. Declare two variables A, B Step 3. Read the positive numbers as A and B Step 3. A ← A + B Step 4. B ← A - B Step 5. A ← A - B Step 6. Display interchanged numbers in A , B Step 7. Stop E.g. A = 7, B= 5 A = 7 + 5 =12 B = 12-5 =7 A= 12 - 7 =5 Dr. Kuppusamy P
  • 9. Problem Statement 2: Design an algorithm and draw the flow chart to exchange two values without using temporary variable. Algorithm Step 1. Start Step 2. Declare two variables A, B Step 3. Read the positive numbers as A and B Step 3. A ← A + B Step 4. B ← A - B Step 5. A ← A - B Step 6. Display interchanged numbers in A , B Step 7. Stop E.g. A = 7, B= 5 A = 7 + 5 =12 B = 12-5 =7 A= 12 - 7 =5 Read the positive numbers to A and B A ← A + B B ← A - B A ← A - B Display interchanged numbers in A , B Stop Start Declare variables A, B Dr. Kuppusamy P
  • 10. Problem Statement 3: Design an algorithm and draw the flow chart to find the sum of individual digits for the given non negative integer. Step 1. Start Step 2. Declare variable n Step 3. Read non negative integer (n) Step 4. Initialize result ← 0 Step 5. Repeat until n > 0 Step 5.1 result ← result + (n % 10) Step 5.2 n ← n / 10 Step 6. Display result Step 7. Stop E.g. Iteration: 1 n = 76 result = 0 + (76 % 10) n = 76/10 Iteration: 2 n = 7 result = 6 + (7 % 10) n = 7/10 Dr. Kuppusamy P
  • 11. Repeat Yes No Problem Statement 3: Design an algorithm and draw the flow chart to find the sum of individual digits for the given non negative integer. Step 1. Start Step 2. Declare variable n Step 3. Read non negative integer (n) Step 4. Initialize result ← 0 Step 5. Repeat until n > 0 Step 5.1 result ← result + (n % 10) Step 5.2 n ← n / 10 Step 6. Display result Step 7. Stop Read the positive number n result ← result + (n % 10) n ← n / 10 Display the result Stop Start Declare variable n Repeat until n >0 Dr. Kuppusamy P
  • 12. Problem Statement 4: Design an algorithm and draw the flow chart to find the sum of given set of n positive integer. Step 1. Start Step 2. Declare variables n, sum, a, i Step 3. Read total numbers value (n) and ‘n’ positive integers in array ‘a’ Step 4. Initialize sum ← 0 , i ← 0 Step 5. Repeat until i < n Step 5.1 sum ← sum + a[i] Step 5.2 i ← i + 1 Step 6. Display sum Step 7. Stop n = 3 a[] = {2, 3, 4} sum = 0 , i=0 Iteration: 1 sum = 0 + 2 i = i +1 Iteration: 2 sum = 2 + 3 i = i +1 Iteration: 3 sum = 5 + 4 i = i +1 Dr. Kuppusamy P
  • 13. Problem Statement 4: Design an algorithm and draw the flow chart to find the sum of given set of n positive integer. Step 1. Start Step 2. Declare variables n, sum, a Step 3. Read total numbers value (n) and ‘n’ positive integers in array ‘a’ Step 4. Initialize sum ← 0, i ← 0, Step 5. Repeat until i < n Step 5.1 sum ← sum + a[i] Step 5.2 i ← i + 1 Step 6. Display sum Step 7. Stop Repeat Yes No Read total numbers value (n) and ‘n’ integers in array ‘a’ sum ← sum + a[i] i ← i + 1 Display the sum Stop Start Declare variable n, sum, a Repeat until i <n Dr. Kuppusamy P
  • 14. Problem Statement 5: Design an algorithm and draw the flow chart to find the number of digits in given number Sample Input 1: 4582 Sample Output 1: The number of digits in 4582 is 4 Algorithm Step 1. Start Step 2. Declare variables Step 3. Read the input Step 4. Initialize count ← 0 Step 4. Repeat until n !=0 Step 5.1 count ← count + 1 Step 5.2 n ← n / 10 Step 6. Display count Step 7. End Iteration: 1 count = 0 + 1 n= 4582 /10 Iteration: 2 count = 1 + 1 n= 458 /10 Iteration: 3 count = 2 + 1 n= 45 /10 Iteration: 4 count = 3 + 1 n= 4 /10 Iteration: 5 n != 0 → False Dr. Kuppusamy P
  • 15. Problem Statement 6: Design an algorithm and draw the flow chart to find Factorial computation of given number Sample Input 1: 4! Sample Output 1: 24 Step 1. Begin Step 2. Declare variables Step 3. Read the decimal number n Step 4. Initialize fact ← 1, i ← 1 Step 4. if (n != 0) Step 4.1. Repeat until 1 to n Step 4.1.1 fact ← fact * i Step 4.1.2 increment i Step 5. Display fact Step 7. End Iteration: 1 fact = 1 * 1 i = i +1 Iteration: 2 fact = 1 * 2 i = i +1 Iteration: 3 fact = 2 *3 i = i +1 Iteration: 4 fact = 6 * 4 i = i +1 Iteration: 5 i < =n → False Dr. Kuppusamy P
  • 16. Problem Statement 7: Design an algorithm and draw the flow chart to find Sine function computation Step 1. Begin. Step 2. Read the input x and n Step 3. Convert x value to radius using rad ← 3.14/180*x. Step 4. Initialize sum ← rad, sign ← -1. Step 5. Repeat for i ← 3 to n in increment by 2. Step 5.1 power ← pow(rad, i). Step 5.2 factorial ← factorial*(i-1)*i. Step 5.3 result ← power / factorial. Step 5.4 sum ← sum + (sign * result). Step 5.5 k ← k*(-1). Step 6. Display the sum as sine series result. Step 7. End. Dr. Kuppusamy P Repeat Yes No Read the input x and n power ← pow(rad, i). factorial ← factorial*(i-1)*i. result ← power / factorial. sum ← sum + (sign * result). k ← k*(-1) Display the sum Stop Start Declare variable Repeat until i <n Initialize sum, sign
  • 17. Problem Statement 8: Design an algorithm and draw the flow chart to generate Fibonacci sequence Step 1. Begin Step 2. Get Non-negative decimal limit n Step 3. Initialize num1 ← 0, num2 ← 1 Step 4. Display num1 and num2 Step 5. Repeat until 1 to n- 2 Step 5.1 num3 ← num1 + num2 Step 5.2 Display num3 Step 5.3 num1 ← num2 Step 5.4 num2 ← num3 Step 6. End Dr. Kuppusamy P Input : 5 Output: 0, 1, 1, 2, 3, 5
  • 18. Problem Statement 9: Design an algorithm and draw the flow chart to Reverse the digits of an integer Step 1. Begin Step 2. Get Non-negative integer num Step 3. Initialize reversed ← 0 Step 4. Repeat until num > 0 Step 4.1 digit ← n % 10 Step 4.2 reversed ← (reversed * 10) + digit; Step 4.3 num ← num / 10 Step 5. Display reversed Step 6. End Dr. Kuppusamy P Input : 598 Output: 895
  • 19. Problem Statement 10: Design an algorithm and draw the flow chart to Decimal to Binary conversion Step 1. Begin Step 2. Get a Positive decimal number (n) Step 3. Initialize result as null Step 4. if (n > 1) Step 4.1. Repeat until n < 2 Step 4.1.1 Remainder ← n % 2 Step 4.1.2 Append remainder with result Step 4.1.3 n ← n / 2 Step 5. Append n with result Step 6. Display the reverse of result Step 7. End Dr. Kuppusamy P Input : 3 Output: 011 Repeat Yes No Read integer n Remainder ← n % 2 Append remainder with result n ← n / 2 Append n with result Display the reverse of result Stop Start Declare variable Initialize result as null Repeat until n<2
  • 20. References Dr. Kuppusamy P • Herbert Schildt, “Java: The Complete Reference”, McGraw-Hill Education, Tenth edition, 2017. • https://www.sitesbay.com