A newbie programmer who happened to be Computer Scientist once asked me this question sometimes ago.

What is an algorithm.

An algorithm is a well-defined step by step procedure that describes how to solve a problem. Algorithms are more precise than informal instructions and do not require any insight to follow; they are still not precise enough for a computer to follow in the form they are written, but are precise enough for a human to know exactly what you mean, so they can then work out how to implement your algorithm, either doing it themselves, or writing a computer program to do it. The other important thing with this level of precision is that we can often make a good estimate of how fast it will be.

For example:

Let’s say you want to create a program which allows the user to enter a number the program will evaluate if the number is even or odd and print the result on the screen.

So I come up with this Algorithm:

1. First, declare 2 variables. (1 for storing the number the user will enter, 1 for storing the remainder after modulus by 2).

2. Give the user a message informing him/her to enter a number.

3. Allow the user to enter a number and store it in the first variable.

4. Divide in modulus mode by 2 and store the remainder in the second variable.

5. Check with conditional statement IF the remainder is equal to 0, Display on the screen (“Entered number is an even number” ELSE Display on the screen ((“Entered number is an odd number”.

Now the above step-by-step process to create our program is what is known as Algorithm.

Algorithms are often expressed using a loosely defined format called pseudo-code , which matches a programming language fairly closely, but leaves out details that could easily be added later by a programmer. Pseudo-code doesn’t have strict rules about the sorts of commands you can use, but it’s halfway between an informal instruction and a specific computer program or flowchart a diagrammatical illustration of the algorithm using symbols.

Below is the implementation of the above algorithm in JAVA:

import java.util.Scanner;

public class CheckNumber{

public static void main(String[] args){

int num, remainder;

System.out.println(“Please enter a number to check even or odd:”;

Scanner inpNum = new Scanner(System.in);

num = inpNum.nextInt();

remainder = num % 2;

if(remainder == 0){

System.out.println(“Entered number is an even number”;



System.out.println (“Entered number is an odd number”;





By creating algorithm you will be able to evaluate all the possible solution to specific problem.

The most important thing to remember about algorithms is that there can be many different algorithms for the same problem, but some are much better than others. It’s a bad programming methodology to start writing computer program without analyzing and write the best algorithms for the problem at hand. I encourage you to study and inculcate into your carrier, the act of algorithm writing.

Keep coding………