Open E-School

Friday, February 24, 1984

Writing computer algorithms – Separating thinking and coding

Date: Tuesday, January 20, 2015
OpenESchool Emagazine

When you start learning how to write computer programs you start with writing basic programs like adding two numbers, subtracting two numbers, checking if a number is odd or even etc. These are all simple programs where you need to apply simple logic which takes not more than 10-15 lines of code. It’s always easy to think and write such code.
But let’s say you have to write a complex program to print a tree of stars like shown below.

It might be difficult for you to write such a program directly using code. Specially people who are beginners to programming face such problems because they have to think and write code at the same time. What you need to understand is that you can separate out the process of thinking and writing code. When you become experienced with programming you can think and write complex programs very fast. But in the beginning you have to learn how to think first and then write code.


In simple words algorithms are simple English statements which define the logic you want to implement step by step. You can compare an algorithm with a cooking recipe. The recipe has the complete procedure to cook a given dish. Only if you follow the recipe step by step you will be able to cook the dish properly. When you become experienced with cooking you can create new dishes of your own very quickly without feeling the need to write down the steps on a piece of paper.

An algorithm is your recipe for a computer program. When you are new to programming you should learn how to write algorithms first. When you write an algorithm you define the complete flow of the program in simple English language. Then when you start writing code you don’t have to worry about the logic which you want to implement. You can code at a high speed because now you already know the exact logic which you want to implement.

An example

Below is an example of an algorithm for a program to add two numbers. See how we breakdown our thought process into simple steps and write them in our own language.

Step 1 : Start
Step 2 : Take a variable x
Step 3 : Take a variable y
Step 4 : Ask the user to enter the first number. Store that number in x
Step 5 : Ask the user to enter the second number. Store that number in y
Step 6 : Take a variable z
Step 7 : Add x and y and store the result in z
Step 8 : Print the value of z
Step 9 : Stop

In the above algorithm we have defined all the steps to add two numbers. Now you can convert this algorithm into a program using any programming language. Writing an algorithm will help you think and organize your thoughts so that when you write a program you can focus on your coding and not get frustrated while coding just because you don’t know what to code !

Rate this article and help us improve

Please Login to rate
Overall ratings: 0 | Rating: out of 5
Previous Article Next Article

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp