Upload
vance-acosta
View
17
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Solving a problem. Different steps in solving a problem. Writing a computer program involves performing the following tasks. Understanding the problem Developing an Algorithm for the problem Writing a Computer Program Testing the Computer program. - PowerPoint PPT Presentation
Citation preview
End Show
Writing a computer program involves performing the following tasks.
1. Understanding the problem
2. Developing an Algorithm for the
problem
3. Writing a Computer Program
4. Testing the Computer program
Different steps in solving a problem
Solving a problem
IT Department - National Institute of Education
End Show
Lets take a problem and try to solve the problem
Add two numbers and display total.
Problem :
IT Department - National Institute of Education
End Show
How do you solve that problem ?
The first task is to understand the problem clearly
STEP 1 – Understand the problem
Here the input should be two numbers.
Find out the inputs ?
IT Department - National Institute of Education
End Show
That is Process.
Find outputs ?
Total.
So there must be some calculation to get the total.
IT Department - National Institute of Education
End Show
STEP 2 – Developing an Algorithm for the problemThe method that used to solve the problem is called algorithm
Algorithm can be represented in two ways
1. Graphically
2. Textually
IT Department - National Institute of Education
Boil water
Add some sugar
Put tea powder to mug
Start
Stop
Serve
A Graphical representation of making a cup of tea
This Representation is called as Flow Chart
IT Department - National Institute of EducationEnd Show
End Show
A graphical representation of the sequence of operations in a program is called Flow Chart.
Flowchart
flowchart shows how data flows and operates
IT Department - National Institute of Education
End Show
Symbols used in Flow chart
Start/Stop
Input/Output
Decision
Flow line
Process
Yes
No
IT Department - National Institute of Education
Calculate total
Start
Stop
A Graphical representation to add two numbers
This Representation is called as Flow Chart
Input two numbers
Display total
IT Department - National Institute of EducationEnd Show
End Show
Draw a flow chart to find adult or child.
Stop
Input Age
If age>=18 Adult child
Start
Yes No
IT Department - National Institute of Education
End Show
Draw a flow chart to cross the road.
Are clear both ways?
Go to pavement
No
Cross the road Wait
Yes
Start
Stop
Look at left & right
IT Department - National Institute of Education
End Show
Draw a flow chart to find the correct key from a bunch keys to open the door.
Can the door be opened
Tryout a key
No
Try the next key
Yes
Start
Stop
IT Department - National Institute of Education
End Show
Input name, Maths and Science marks and calculate Total.
Display Name & Total Marks .
Solve & design the above problem in Flow chart.
Problem Solving 1
IT Department - National Institute of Education
Start
Input Name, Maths Mks , Science Mks
Total= Maths + Science
Display Name,Total
Stop
Conti..
IT Department - National Institute of Education
End Show
End Show
Problem Solving 2
Draw Flow chat to input Average Marks and display Pass or fail
(If Average>= 60 , “Pass” otherwise “Fail”)
IT Department - National Institute of Education
End Show
Start
If Avg>=60
No
PASS
Display Grade
FAIL
Stop
Yes
Input Average
IT Department - National Institute of Education
End Show
75 - 100 “A”65 - 74 “B”55 - 64 “C”45 - 54 “S”0 - 44 “F”
Draw a flow chart to input Average Marks and find the grade according to the grade System given below.
Problem Solving 3
IT Department - National Institute of Education
End Show
Input Avg If Avg>=75
If Avg>=65
If Avg>=55
If Avg>=45
Stop
Start Display A
Display B
Display C
Display S
Yes
Yes
Yes
Yes
No
No
No
No
Display F
IT Department - National Institute of Education
End Show
Start
Is Number < =10
No
Print Number
Stop
Yes
Number=1
Number=Number+1
Draw a flow chart to print numbers from1 to 10
IT Department - National Institute of Education
End Show
One of the textual representation of algorithm is Pseudo code.
Pseudo Code
IT Department - National Institute of Education
End Show
Begin
Pseudo Code for adding two numbers
End.
Input first number and second number
Total = first Number + Second Number
output Total
IT Department - National Institute of Education
End Show
Begin Input Maths Marks ,Science Marks Total = Maths + Science Average = Total / 2 If Average >= 60 then Grade= “PASS” Else Grade= “FAIL” End if Display Total , Average , GradeEnd
Write a pseudo code to take maths and science marks , calculate total, average and display grade.(If average >=60, “Pass” otherwise “Fail”.
IT Department - National Institute of Education
End Show
75 - 100 “A”65 - 74 “B”55 - 64 “C”45 - 54 “S”0 - 44 “F”
Write a pseudo code to input Average Marks and find the grade according to the grade System given below.
IT Department - National Institute of Education
End Show
Begin
Input Avg Mks
If Avg >=75 then Grade = “A” Else
If Avg >=65 then Grade =“ B” Else
If Avg >=55 then Grade = “C” Else
If Avg >= 45 then Grade =“ S” Else
Grade = “W”
End if
End if
End if
End if
Display Grade
End
IT Department - National Institute of Education