You are on page 1of 11

DIVIDE AND CONQUER

K. MORGAN
WHAT IS THE DIVIDE AND CONQUER APPROACH?
The divide and conquer approach is breaking a problem into sub problems until it
becomes simple enough to be solved directly. Each individual sub problem is then
combined to make one complete solution.
IPO
CHART
Computer systems include hardware used for input,

processing, output and storage. These are the functions of a

computer system. Problems can be solved in stages. Computer

problems can be broken down into 3 parts: Input, Processing and

Output. In defining the solution to problems, you must know:


1. What information will be processed

2. How that information will be processed

3. What results will be output

4. Any information that needs to be stored either during the process or to be

kept for another time


IPO CHART is used to decompose a problem into its significant parts as follows:

Input Processing Output

What is given All the instructions that must be The expected results

executed to transform what is given

into the expected results

I
Key Words (IPO - Input, Processing and Output)

Input Processing Output

Read Calculate Display

Enter Get & accept Output

Input Find Print

Write

Return
1Example: Prompt the user to enter name, year of birth and current
year calculate and display the users age.

Input Processing Output

name Get/Accept name Age

year_of_birth year_of_birth

current_year current_year

Calculate Age
A VARIABLE is a storage location
in the computer’s memory that is
subject to change. Underscores and
initial capitalization are used for
variables with more than one word to
link each word.

Eg: year_of_birth or YearOfBirth

A CONSTANT is a variable whose


value does not change. eg. Pi “π” is a
constant
Example 3:Prompt the user to input the radius of a circle, calculate and return the area.

Input Processing Output

Pi<- 3.14 Read pi Area

radius radius

Calculate Area

Return Area
Class Work
1. Write a program that prompts the users to input
the height of three friends, find and output the
average height.

2. Prompt the user to input the cost of a tile and


the numbers of tiles needed to tile a room. Find
and display the total cost of tiling the rooms.

You might also like