Solve Coding Problem With a Simple Four Step Process

If anyone dream to be developer or is studying programming,the most important thing is solving coding problem.

As far I had research, there are 4 steps for solving coding problems which will help in solving codes.

I got this method from the book ”HOW TO SOLVE IT” by GEORGE POLYA , published in 1945.
Many programmers has used this method as well as many computer science professors taught this.

Lets go forward to see how this method works, we will use C language for this.

Now ,let’s understand this practically:-
Let’s take a problem

Create a function that multiply two numbers and returns a value.

Source: Pinterest

The 4 steps to solve the problems are as follows :-

  1. Understand the problem
  2. Make a plan
  3. Execute the plan
  4. Revision of previous three steps

Step 1 – Understand the Problem

Always be sure to understand the problem by reading it at-least 3 times before solving. This is the most important method for problem solving.
Many times we doesn’t clearly understand what’s the problem, which takes extra time later.

  1. INPUT– For the above problem, if we understood clearly many things came into our minds like-what would be the number and then assume what will be the inputs.

//inputs:2, 4 (Multiplication of two numbers)

2. OUTPUT – Similarly assume the output, we have to return a value i.e. the result/multiplication of two numbers.



Step 2 – Make a Plan for Solving the Problem

Think about how to solve the given problem after that write the pseudo-code (algorithm) on your own.

For example for this problem we can write as:-
// Create two variables to store two inputs (num1 and num2).
// Create a function named multiplication() having two arguments/parameters num1 and num2.
// Create a variable mult to store multiplication of num1 & num2.
// Return as output the multiplication of two variables.


Step 3 – Execute the Plan

Now using pseudo code, we have to write final code
(Write pseudo-code line by line and focus on logic and steps)

int multiplication(num1, num2)
{
    int mult;
    mult = num1*num2;
    return mult;
}

Step 4 – Revision of Previous Three Steps

Take a look at the code whether any improvements can be done in the code to make it more short and to the point.
One way is that using implicit return instead of variable.

int multiplication(num1, num2)
{
    return num1*num2;
}

Summary

  • In this article we have seen four ways to solve a problem.
  • Programming is simple if you practice more.
  • Skills will get improve after regular practice.

Click here to download How to solve it EBook .


CsCode

One thought on “Solve Coding Problem With a Simple Four Step Process

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top