Back to Home

### Problem Solving With Computer

1.1 Introduction;
There are number of problems occurs in our daily life. These problems should be solved carefully to get the desired solution. Sometimes, we may have to calculate simple interest, we may have to prepare mark sheet, salary sheet and may have to do numerous sophisticated calculations.

A computer is a dumb machine which cannot do anything alone without our instructions. We have to give instructions to the computer to do certain specific tasks. So, there should be software and the software is the collection of programs, where programs are the set of instructions which are given by the users. The software is written to solve a particular problem that takes some input from users, process it and give the meaningful result as output. If the instructions are not correct then the computer gives wrong result.

Just writing code is not sufficient to solve a problem. Program must be planned before coding in any computer language available. There are many activities to be done before and after writing code for the software development.

Stages while solving a problem using computer:
1. Problem Analysis
2. Algorithm Development
3. Flowcharting
4. Coding
5. Compilation and Execution
6. Debugging and Testing
7. Documentation

1.1 Problem analysis
Problem analysis is the process of becoming familiar with the problem. We need to analyze and understand it well before solving a problem. The user’s requirements cannot be fulfilled without clear understanding of his/her problem in depth. Inadequate identification of problem may cause program less useful and insufficient. In this phase, we determine the requirements like variables, functions, etc. to solve the problem. That means we gather the required resources to solve the problem defined in the problem definition phase. We also determine the bounds of the solution. For example: Banking solution, Hospital Medical study etc.

1.2 Algorithms and Flowchart

Algorithm: An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code - something resembling C language or Pascal, but with some statements in English rather than within the programming language. Developing an efficient algorithm requires lot of practice and skill. It must be noted that an efficient algorithm is one which is capable of giving the solution to the problem by using minimum resources of the system such as memory and processor’s time. Algorithm is a language independent, well structured and detailed. It will enable the programmer to translate into a computer program using any high-level language.
Features of Algorithm:
Following features should be present in an algorithm:
1. Proper understanding of the problem
2. Use of procedures/functions to emphasize modularity
3. Choice of variable names
4. Documentation of the program

Criteria to be following by an algorithm:

The following is the criteria to be followed by an algorithm:
Input: There should be zero or more values which are to be supplied.
Output: At least one result is to be produced.
Definiteness: Each step must be clear and unambiguous.
Finiteness: If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps.
Effectiveness: Each step must be sufficiently basic that a person using only paper and pencil can in principle carry it out. In addition, not only each step is definite, it must also be feasible.

Example 1: Algorithm to compute and display the sum of two numbers.
1. Start
2. Read two numbers a and b
3. Calculate the sum of a and b and store it in sum.
4. Display the value of sum.
5. Stop

Example 2: Algorithm to computer the average of three numbers.
1. Start
2. Read three numbers a, b and c
3. Calculate the sum of a, b and c then divide the sum by 3 and store it in average.
4. Display the value of average
5. Stop

Example 3: Algorithm to calculate the factorial of a given number.
1. Start