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

Problem Solving

Recap
An algorithm is a formal sequence of instructions that defines the
solution to a problem.
An algorithm is like a recipe (instructions to prepare a meal).
Defining a Problem
Questions to ask yourself when baking Questions to ask oneself when solving
a problem
a cake
What do I need in order to bake this What is my input? This is always
cake? This will be your input defined in your problem statement
What result that am I expecting to What is the output- This is end result
get? This is the output How do I get to the expected output-
What steps do I need to perform in This is the process
order to bake this cake?- This is
Process (This will help you create a
path to your solution)
Lets create a defining diagram
Now that you know how to identify a problem lets learn how to
create a defining diagram.
A defining diagram allows us to define a problem. It also called an IPO
chart.
Creating a defining diagram
Remember to break up your problem into its components.
Write an algorithm that accepts two numbers and finds and prints the
sum of the two numbers

Steps I is for Input


O is for out put

1. Draw a defining diagram

What
is P
I P 0
for?
Add the input, processes and output to the table

I P 0
Two numbers 1. Prompt the user to Sum of two numbers
enter numbers
2. Accept the two numbers
3. Add the two numbers
4. Print the sum of two
numbers
Good Job!!

Now that you know how create a defining diagram go ahead and
create defining diagrams for the problem statements below:
1. Write an algorithm that accepts two numbers. Your algorithm
should divide the first number by the second number. Print the
answer.
2. Write an algorithm that accepts four numbers. Find and print the
sum.
3. Write an algorithm that accepts the length of the side of a square.
Find and print the perimeter of the square.
4) Write an algorithm that accepts three number numbers. Find and
print the average.