Вы находитесь на странице: 1из 25

Solving a problem

Different steps in solving a problem 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

End Show
IT Department - National Institute of Education

Lets take a problem and try to solve the problem

Problem :
Add two numbers and display total.

End Show
IT Department - National Institute of Education

STEP 1 Understand the problem


How do you solve that problem ? The first task is to understand the problem clearly

Find out the inputs ?

Here the input should be two numbers.

End Show
IT Department - National Institute of Education

Find outputs ?

Total.
So there must be some calculation to get the total. That is Process.

End Show
IT Department - National Institute of Education

STEP 2 Developing an Algorithm for the problem


The method that used to solve the problem is called algorithm Algorithm can be represented in two ways 1. Graphically 2. Textually

End Show
IT Department - National Institute of Education

A Graphical representation of making a cup of tea Start Boil water Put tea powder to mug Add some sugar Serve Stop This Representation is called as Flow Chart
End Show

IT Department - National Institute of Education

Flowchart
A graphical representation of the sequence of operations in a program is called Flow Chart.

flowchart shows how data flows and operates

End Show
IT Department - National Institute of Education

Symbols used in Flow chart


Start/Stop Process Decision

Yes

No

Input/Output Flow line

End Show
IT Department - National Institute of Education

A Graphical representation to add two numbers


Start
Input two numbers

Calculate total
Display total

Stop

This Representation is called as Flow Chart


IT Department - National Institute of Education

End Show

Draw a flow chart to find adult or child.


Start

Input Age

Adult

Yes If age>=18

No

child

Stop
IT Department - National Institute of Education

End Show

Draw a flow chart to cross the road.


Start
Go to pavement
Look at left & right

Yes

Are clear both ways?

No

Cross the road

Wait
Stop
End Show

IT Department - National Institute of Education

Draw a flow chart to find the correct key from a bunch keys to open the door.

Start

Tryout a key

Can the door be opened No Try the next key

Yes

Stop
IT Department - National Institute of Education

End Show

Problem Solving 1

Input name, Maths and Science marks and calculate Total.


Display Name & Total Marks . Solve & design the above problem in Flow chart.

End Show
IT Department - National Institute of Education

Conti..

Start
Input Name, Maths Mks , Science Mks

Total= Maths + Science

Display Name,Total

Stop End Show


IT Department - National Institute of Education

Problem Solving 2

Draw Flow chat to input Average Marks and display Pass or fail
(If Average>= 60 , Pass otherwise Fail)

End Show
IT Department - National Institute of Education

Start

Input Average

Yes

If Avg>=60

No

PASS

FAIL

Display Grade

Stop IT Department - National Institute of Education

End Show

Problem Solving 3 Draw a flow chart to input Average Marks and find the grade according to the grade System given below.
75 - 100 65 - 74 55 - 64 45 - 54 0 - 44 A B C S F
End Show
IT Department - National Institute of Education

Start

Input Avg

If Avg>=75
No

Yes

Display A

If Avg>=65
No

Yes

Display B

If Avg>=55
No

Yes

Display C

If Avg>=45
No

Yes

Display S

Display F
End Show

Stop
IT Department - National Institute of Education

Draw a flow chart to print numbers from1 to 10


Start
Number=1

No

Is Number < =10

Number=Number+1

Yes
Print Number Stop End Show
IT Department - National Institute of Education

Pseudo Code

One of the textual representation of algorithm is Pseudo code.

End Show
IT Department - National Institute of Education

Pseudo Code for adding two numbers

Begin
Input first number and second number Total = first Number + Second Number output Total End.

End Show
IT Department - National Institute of Education

Write a pseudo code to take maths and science marks , calculate total, average and display grade. (If average >=60, Pass otherwise Fail. 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 , Grade End
IT Department - National Institute of Education

End Show

Write a pseudo code to input Average Marks and find the grade according to the grade System given below.
75 - 100 65 - 74 55 - 64 45 - 54 0 - 44 A B C S F
End Show
IT Department - National Institute of Education

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

End Show

Write a Pseudo code to display numbers from 1 to 10

Begin
Number=1 Do While Number <=10 Print Number Number=Number + 1 End while End
End Show
IT Department - National Institute of Education

Вам также может понравиться