Pseudocode Tutorial - The Basics

shabbir's Avatar author of Pseudocode Tutorial - The Basics
This is an article on Pseudocode Tutorial - The Basics in Programming.
Pseudocode is a compact and informal high-level description of a program using the conventions of a programming language, but intended more for humans.

Why Pseudocode?



Pseudocode omits programming level details (like declaration of variables, looping syntax ...) and so it makes things very easy to understand for human being and implement it in any programming language easily.

How to Write Pseudocode?



There is no pseudocode standard syntax and so at times it becomes slightly confusing when writing Pseudocode and so let us understand pseudo code with an example.

Example

Let us take a very simple program of pascal triangle in C++.

Code: Cpp
#include <iostream>
using namespace std;

int main(void)
{
    int num;
    cout<<"Enter Number"<<endl;
    cin>>num;
    if(num<1)
    {
        cout<<"Are you gone mad? Number should be greater than 1"<<endl;
        return 0;
    }
    for(int i=1;i<=num;i++)
    {
        for(int k=0;k<i;k++)
        {
            cout<<"*";
        }
        cout<<endl;
    }
    return 0;
}
Now let us convert the above program into pseudocode using syntax from the following pseudocode guide
Code:
Input Variable num
IF num is less than 1 THEN
	Display Error Message
	Exit Program
ENDIF 
FOR i = 1 to num step 1 DO 
	FOR k = 1 to i step 1 DO
		Display *
	ENDFOR
	Display linebreak
ENDFOR

Final Thoughts



I have tried to explain the basics of Pseudocode but if you have more questions, post them in comments below.
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
Short but effective!!

Nice work Sir!!
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Thanks.