0% found this document useful (0 votes)
5 views

1.programming and Problem Solving-1

This document discusses problem solving with computers. It explains that solving a problem with a computer involves defining the problem, analyzing it, developing an algorithm, writing a program, testing the program, and executing it to get a result. It also discusses the difficulties of writing instructions for a computer to follow and introduces basic concepts like algorithms and flowcharts.

Uploaded by

Ebrahim Awadh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

1.programming and Problem Solving-1

This document discusses problem solving with computers. It explains that solving a problem with a computer involves defining the problem, analyzing it, developing an algorithm, writing a program, testing the program, and executing it to get a result. It also discusses the difficulties of writing instructions for a computer to follow and introduces basic concepts like algorithms and flowcharts.

Uploaded by

Ebrahim Awadh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

General Problem Solving

Concepts

Problem Solving in Everyday Life

People make decisions every day to solve problems that affect their lives.
The problems may be as unimportant as what to watch on television or as
important as choosing a new job. If a bad decision is made, time and resources are
lost, so it’s important that people know how to make decisions well.

Types of Problems that can be solved on computers

1. Computational :
problems involving some kind of mathematical processing
2. Logical :
Problems involving relational or logical processing
3. Repetitive :
Problems involving repeating a set of mathematical and/or logical
instructions.

-----------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.……………………………….…………..….. Programming and problem Solving

1
Problem Solving with computers:

Solving a Problem using a computer passes by certain steps:

Step 1: Problem definition and specification, which is given by the full and
detailed description of the problem.

Step 2: Problem analysis. Based on the definition of the problem and data to be
used, in this step the problem is to be analyzed to its main components.

Step 3: Algorithm development. Solving the problem in the form of an algorithm.


The sequence of instructions must be clear and precise.

Step 4: Program writing (Program coding). According to the algorithm, a


program could be written using a given programming language.

Step 5: Program transfer to the computer. The first form of the program is
known as the source program. This step includes also correcting syntax and
semantic errors in the program.

Step 6: Program testing and translation. The compiler translates the error-free,
source program into object program, after being tested using several data sets to
detect any logic errors.

Step 7: Execution of program and output result.

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 2 )…..….. Programming and problem Solving


Difficulties with Problem Solving

The problem-solving process is not easy. It takes practice and time to perfect, but
in the long run the process proves to be of great benefit.

When solving problems on the computer, one of the most difficult tasks for the
problem solver is writing the instructions. Take the task of deciding which number
is the largest from a group of three numbers. Almost anyone can immediately tell
which is the largest, but many cannot explain the steps they followed to arrive at it.
Most people will say, “I can’t explain how I know, I just know it!” This
explanation is not good enough for the computer. The computer is a tool that will
perform only tasks that the user can explain.

The computer has a specific system of communication that programmers and users
must learn. This system demands that no step in the solution to a problem be left
unstated and that all steps be in the proper order. You must assume the computer
knows nothing except what you tell it and think of it as an ignorant but efficient aid
to problem solving.

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 3 )…..….. Programming and problem Solving


Algorithm & Flowchart
Algorithm:
An algorithm is a given set of well defined, unambiguous processes (actions) for
solving a problem in a finite number of steps.

Flowchart:

A flowchart represents a good, visible graph-wise way of solving algorithms.


It is a block diagram that uses predefined symbols and interconnecting lines to
represent the logic and sequence of specific program operation.

Basic Program Flowcharting Symbols:

Terminal (start / stop )

Input / Output Operation

Processing ( calculation and storing


operation)

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 4 )…..….. Programming and problem Solving


Decision (conditional branching)

Subprogram call

Flow lines (direction)

Connection

Types of program flowcharts:

We can distinguish between 3 main different controls in the algorithms presented


by flowcharts. These controls are known as the types of program flowcharts:

1. Sequential flowchart

2. Branching (jump) flowchart

3. Loop (repetition) flowchart

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 5 )…..….. Programming and problem Solving


Depending on the given problem, sequential, branching and looping parts are
combined in different ways to represent the solution of the given problem.

Each type of flowchart could be described by its features which are represented in
the following paragraphs.

Generally, the problem should be analyzed before deciding about the solution. The
logical order of steps of the solution indicates the type of flowcharts to be used, i.e.
the final form of the solution.

In addition to these three main types, nested loops in flowcharts represent another
flowchart type which is used when the solution includes the dependence of one
loop parameters on the parameters of another loop.

1. Sequential flowchart

It is simplest type of flowcharts, involving no decision (i.e. no branches or


loops). Fig. 1 gives an example for this type of flowcharts. When such a
program is executed, each statement will be carried out respecting the order
given by the flowchart.

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 6 )…..….. Programming and problem Solving


Fig. 1: A sequential flowchart.

2. Branching (jump) flowchart

In this type of flowcharts, one or more decision boxes are introduced, and
the action taken depends upon whether the result of the decision test is true
(yes) or false (no). This operation is illustrated by Fig. 2.

Fig. 2: Branching flowchart.

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 7 )…..….. Programming and problem Solving


3. Loop (repetition) flowchart

A loop represents a segment which may be repeated a definite or indefinite


number of times. In Fig. 3, the instructions are executed one or more cycles when
the logical expression is true. When the logical expression become no longer true,
the control is transferred to the instruction outside the loop.

Fig. 3: Looping flowcharts

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 8 )…..….. Programming and problem Solving


 Nested loops in flowchart

Sometimes, there is need to include a logical decision which is dependent on


the response to another logical expression, which is also performed inside
the loop. This is known as nested looping, where their use is dependent in
mutual way.

------------------------------------------------------------------------------------------------------------------------------

Dr. Omaima Bahaidara.…… ( 9 )…..….. Programming and problem Solving

You might also like