Problem Solving Using Computer
Problem solving is the process of finding solutions to problems encountered in life.
A computer is a tool to solve a problem. Using a computer as a problem solving tool following steps are involved.
Problem Analysis
A clearly defined problem is already half the solution. Analyzing the problem require us to identify the following:
- Input(s) to the problem
- Output(s) expected from the problem
- Special constraints or condition (if any)
- Any Formulas or equations to be used
For example, Compute the Area of a Circle:
Inputs: radius of a circle
Outputs: Area of a circle
Formula: Area = 3.1415*radius*radius
i.e. A = PI*r^2
Algorithm Development & Flowcharting
Algorithm
An algorithm is an step-by-step procedure for solving a problem in a finite number of steps.
An algorithm must possess following characteristics:
- Finiteness: An algorithm should have finite number of steps and it should end after a finite time.
- Input: An algorithm may have many inputs or no inputs at all.
- Output: It should result at least one output.
- Definiteness: Each step must be clear, well-defined and precise. There should be no any ambiguity.
- Effectiveness: Each step must be simple and should take a finite amount of time.
Following guidelines must be followed while develping an algorithm.
- An algorithm will be enclosed by START (or BEGIN) and STOP (or END).
- To accept data from user, generally used statements are INPUT, READ, GET or OBTAIN.
- To display result or any message, generally used statements are PRINT, DISPLAY, or WRITE.
- Generally, COMPUTE or CALCULATE is used while describing mathematical expressions and based on situation relevant operators can be used.
Flowchart
Flowchart is basically a pictorial or diagrammatic representation of an algorithm using standard symbols.
To express different operations in the flowchart various standard symbols are used. All symbols are connected among themselves in order to show the flow of information and processing. Different symbols as prescribed by American National Standard Institute (ANSI) which are frequently required while drawing flowchart are tabulated below:
Example of Algorithm and Flowchart
Coding
Coding is the real job of programmer. The algorithm and flowchart developed is converted into programming language like C, C++, .NET, JAVA, Python which is actually the source code.
Compilation & Execution
The source code written in any programming language is not directly executed by the computer. It should be translated into to the machine readable format i.e. actual machine language. The process of translation of source code into the target code is called the compilation. Each programming language has its own compiler program that translates the source code into its target code. The converted program in actual machine language is then executed by the computer which is known as program execution.
Debugging & Testing
A written program may have errors, some errors can be detected by the language compilers and some errors can not be identified by the compiler and occured during the program run. Common types of errors are
- Syntax Errors:Identified by compiler at the program compilation time.
- Logical Errors: Not identified by the compiler at compile time and identified at the execution time. e.g. misuse of operators
So testing is the process of checking the program for its correct functionality by executing the program with some input data set and observing the output of the program.
Program Documentation
From the start of the problem solving to the end of the implementation of the program, all the tasks should be documented i.e. kept for future reference. It is also the important part of the problem solving or program development. Documentation may be of two types
- Technical Documentation known as programmer's documentations which includes the problem analysis to implementation details for that program. It is needed for future reference for any modification, update of the program.
- User manual is the documentation prepared for the end-user of the program that guides the user how to operate the program.