A computer cannot think, so this means that in order to get it to do any useful work, a user must provide it with a program. A program is a list of instructions that describe how to solve a particular problem, written in a language that a computer can understand, although programming a computer is a lot more involved than simply writing a list of instructions. Problem solving is a crucial component of programming and a broadly defined useful skill.
It is a skill you already know a great deal about, one which you use every day, but one which you probably have never studied methodically. Initially, you will probably spend a lot of time in the laboratory entering the programs. Later you will spend more time removing the errors that inevitably will be present in your programs. Resist the temptation to start entering your program as soon as you have some idea how to write it. Instead, take your time and think carefully about the problem and its solution before you write any program instructions.
This means you must first recognize the problem that exists, and clarify what the problem is before you begin your programming tasks. Before you write a program to solve a particular problem, you must consider carefully all the aspects of the problem and then develop and organize its solution to fit the problem at hand. You must state the problem and get a clear understanding of what is required for its solution in order to begin the process of problem solving. Although this step sounds easy, it can be the most critical part of problem solving and must be done as accurately as possible.
You must study the problem carefully, eliminating aspects that are unimportant and zeroing in on the root problem. This process is called abstraction. If the problem is not totally defined, you should request more information from the person or program posing the problem. That is the first step; the second is the analysis.
Here you must understand what the problem asks you to do. Gain a clearer understanding of what the problem is asking and then eliminate unnecessary information, identify the program's inputs, its desired outputs, and then define any formulas, requirements, or constraints on the solution. Identify what information is to be supplied by the program's data and what results should be computed and displayed accordingly. Determine the required form and units in which the results should be displayed (for example, as a table with specific column headings). After the analysis comes the design.
Break down the problem into smaller subproblems, which will make each task smaller and easier to manage. Flow-charts (a chart that shows the program flow) are used in this stage to help break down the problem. Once enough design detail has been added, develop a list of steps called an algorithm to solve each subproblem, and verify that the algorithm solves the problem as intended. Writing the algorithm is often the most difficult part of the problem-solving process.
Once you have an algorithm, you should verify that it is correct before proceeding further. The algorithm should be complete, cover all parts of the problem, unambiguous, deterministic and finite. The next step is the implementation. Implement the algorithm as a program in order to annunciate its criteria. Knowledge of a particular programming language is required because each algorithm step must be converted into a statement in that programming language.
At the end, test the completed program and verify that it works as expected. Check the results if they are valid, make sure that the solution you gave is the solution to the problem. Don't rely on just one test case; run the program using several sets of data. Once you have written the program out, check your solution by carefully performing each instruction as the computer would. Compare these results with the expected results, and make any necessary corrections to your program.