Introduction to ICT
Lecture # 1
Topic: Problem Solving
Problem solving
Topics to be Algorithms
covered: Flowcharts
Problem solving is a process of identifying a problem and finding
the best solution of it.
Problem solving is a well organized approach.
A problem is the one that does not contain ambiguities. It must be
easy to understand.
A problem may be solved in different ways. Different strategies,
Problem techniques and tools used to solve a problem.
Solving Computers are used as tools to solve complex problems by
developing computer programs.
Different problem solving techniques are as follows:
Program
Algorithms
Flowchart
A set of instructions that tells a computer what to do is called
program.
Program A computer program written in programming languages.
A person who develops a program is called programmer.
A programmer has to go through stages to develop a computer
program:
Program 1. Defining and analyzing a problem
Development 2.
3.
Designing an algorithm
Coding or writing the program
Process 4. Testing program
5. Final documentation
In this step, a programmer studies the problem.
Studying a problem is necessary because it helps a programmer
Defining and decide about the following:
analyzing a The fact and figures which are necessary for developing the
programs.
problem The way in which program is designed.
The language in which program will be suitable.
Desired out of the program.
The programmer designs an algorithm to help visualize possible
alternatives in a program.
Algorithm:
An algorithm is a sequence of steps that must be carried out before
a programmer starts preparing the program.
Designing an An algorithm is a step-by-step procedure to solve a problem.
algorithm It is easier to write algorithm before writing the actual computer
program.
Properties of algorithm:
Given problem should be broken into meaningful steps.
The steps should be numbered sequentially.
The steps should be descriptive.
ALGORITHM BUILDING BLOCKS
All problems can be solved by employing any one of the following
building blocks or their combinations:
ALGORITHM 1. Sequences (of instructions).
2. Conditionals .
BUILDING 3. Loops (repetition). {Will discuss about it in “Programming
BLOCKS Fundamental Course” }
An algorithm is used any one of the building blocks or its
combination.
A sequence of instructions that are executed in the precise order
Sequences they are written in:
Select between alternate courses of action depending upon the
Conditionals evaluation of condition:
Toss a coin, if the head will occur, then I will not do my homework
Example of assignment. If the tail will occur, then I will do my homework
assignment.
Conditionals So, the conditions always have one of two outcomes and course of
action is determine accordingly.
The following algorithm inputs two numbers, calculate sum and
then displays the result on screen.
1. Start
2. Input a
Example 1 3. Input b
4. Sum= a+b
5. Print sum
6. End
The following algorithm inputs radius from the user and calculates
the area of circle.
1. Start
2. Input radius in r
Example 2 3. Area=3.14*r*r
4. Print area
5. End
To display the larger number out of the given three numbers.
1. Start
2. Input n1,n2,n3
3. If n1>n2 and n1>n3 then
Example 3 4. Print n1 is larger
5. else If n2>n3
6. Print n2 is larger
7. else Print n3 is larger
8. End
Reduced complexity
Advantages of Increased flexibility
Algorithms Ease of understanding
Flowchart is the graphical representation of an algorithm.
It is a way of visually presenting the flow of data, operations
performed on data and sequence of these operations.
Flowchart Uses:
Shows steps of an algorithm
Used to understand the flow of program
Used to improve the logic for problem solving
Can be reviewed and debugged easily
Flowchart
elements
Example 1
Example 2
A company plans to pay bonus to their employees, the details are
given below:
Those earning Rs. 30,000 or above are to be paid 20 percent of
their salary.
Practice Those earning less than Rs. 30,000 are to be paid Rs. 1000.
The input records contain the employee number, name and salary
Example of the employees.
The output to be printed should contain the employee number,
name, amount of bonus and new salary to be paid to each
employee.
• HINT: Formula to calculate Bonus is: