3. SOLVING PROBLEMS WITH COMPUTER
Computer works by obeying a sequence of
instructions, which constitutes a program.
To solve a problem with computer, there
must be a program to solve it.
A program needs careful planning, good
A problem can be solved by writing a
program in one of many programming
languages, such as C++, Java, Pascal, and
4. TO SOLVE A PROBLEM USING A COMPUTER
The following are needed:
Know strategy (program)
5. STEPS INVOLVED IN SOLVING A PROBLEM
Understand the problem.
Breaking the problem into manageable pieces.
Designing a solution.
Considering alternatives to the solution and refining
Implementing the solution.
Testing the solution and fixing any problems that
6. PROGRAM DEVELOPMENT CYCLE
Analyse: Define the problem - Have a clear idea of
what data (or input) are given and the relationship
between the input and the desired output.
Design: Plan the solution to the problem - logical
sequence of precise steps that solve the problem.
Such a sequence of steps is called an algorithm.
Choose the interface: Select the objects - how the
input will be obtained and how the output will be
displayed. Then create objects to receive the input
and display the output.
Code: Translate the algorithm into a programming
language - Coding is the technical word for writing
the program. During this stage, the program is written
in programming language of choice and entered into
o Test and debug: Locate and remove any errors
in the program - Testing is the process of finding
errors in a program, and debugging is the
process of correcting errors that are found.
many errors occurring due to typing mistakes,
flaws in the algorithm, or incorrect usages of the
programming language rules only can be
uncovered and corrected by careful detective
o Complete the documentation: Organize all the
material that describes the program -
Documentation is intended to allow another
person or the programmer at a later date, to
understand the program. Internal documentation
consists of statements in the program that are
not executed, but point out the purposes of
various parts of the program.
Algorithm is a set of instructions which is taken in
order to lead to a solution.
Algorithm consist of a sequence of operation for the
particular solution of the stated problem.
It does not have to be written in computer
Algorithms have a definite beginning and a definite
end, and a finite number of steps.
9. PROPERTIES OF ALGORITHM
Must be able to determine after a finite number of
steps e.g listing all counting numbers is not an
The steps must be clearly stated
The input (Data) must be clear and well defined
Given correct input, the algorithm must give correct
An algorithm must be efficient in terms of time
consumption and computer memory space.
10. HOW TO DEVELOP A PROGRAM
Design the algorithm
Converting the algorithm into computer program
Debugging and testing of the program
11. QUALITIES OF A GOOD ALGORITHM
Inputs and outputs should be defined precisely.
Each steps in algorithm should be clear and
Algorithm should be most effective among many
different ways to solve a problem.
An algorithm shouldn't have computer code.
Instead, the algorithm should be written in such a
way that, it can be used in similar programming
12. EXAMPLE OF A SIMPLE ADDITION ALGORITHM
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result
Step 5: Display sum
Step 6: Stop
13. GIVEN VALUES OF THE VARIABLE P, Q, R,
COMPUTE THE VALUE OF H=6P+8Q-R THEN
Get values of p, q, and r
Report the resulting value of H
14. WRITE THE ALGORITHM FOR THE PROGRAM WHEN TAKES IN VALUES
OF A, B, C, D, E AND Y AND COMPUTE X= A.Y.Y.Y.Y + B.Y.Y.Y +
Get values of A, B, C, D, E, Y
Report the resulting value of X
15. FLOW CHART
Flow chart is a diagrammatic representation of an
algorithm or a program.
A flow chart is a type of diagram representing a
process using different symbols containing
information about steps or a sequence of events.
Flowcharts are helpful for:
Aiding understanding of relationships among different
Collecting data about a particular process
Helping with decision making
Measuring the performance of a process
Depicting the structure of a process
Tracking the process flow
Highlighting important steps and eliminating the
A flowchart consists of special geometric symbols
The main advantage of using a flowchart
to plan a task is that it provides a pictorial
representation of the task, which makes
the logic easier to follow. We can clearly
see every step and how each step is
connected to the next.
The major disadvantage with flowcharts
is that when a program is very large, the
flowcharts may continue for many pages,
making them difficult to follow and modify.
17. A TABLE OF THE FLOWCHART SYMBOLS ADOPTED BY THE
AMERICAN NATIONAL STANDARDS INSTITUTE (ANSI)
19. GENERAL RULES FOR FLOW CHARTING
1. All boxes of the flowchart are connected with Arrows. (Not
2. Flowchart symbols have an entry point on the top of the
symbol with no other entry points. The exit point for all
flowchart symbols is on the bottom except for the Decision
3. The Decision symbol has two exit points; these can be on
the sides or the bottom and one side.
4. Generally a flowchart will flow from top to bottom. However,
an upward flow can be shown as long as it does not exceed 3
5. Connectors are used to connect breaks in the flowchart.
• From one page to another page.
• From the bottom of the page to the top of the same page.
• An upward flow of more than 3 symbols
6. Subroutines and Interrupt programs have their own and
2. Draw the flow chart of the program which computes Z=2y+3x+3
3. Draw the flow chart of the program which computes the gradient of the line
joining (x1, y1) and (x2, y2)
Pseudocode is an abbreviated version of actual
computer code (hence, pseudocode). The
geometric symbols used in flowcharts are replaced
by English-like statements that outline the process.
Pseudocode allows the programmer to focus on the
steps required to solve a problem rather than on
how to use the computer language.
Pseudocode has several advantages. It is compact
and probably will not extend for many pages as
flowcharts commonly do.
24. PROGRAMMING TOOLS
A programming tool may be any software program
or utility that aids software developers or
programmers in creating, editing, debugging,
maintaining and/or performing any programming or
Programming tools were initially designed to
support or complement programming languages by
providing the functionality and features these
languages did not have.
Compilers, linkers, assemblers, disassemblers,
load testers, performance analysts, GUI
development tools and code editors are also all
forms of programming tools.