Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/articles/programming/)
-   -   Pseudocode Tutorial - The Basics (http://www.go4expert.com/articles/pseudocode-tutorial-basics-t25593/)

shabbir 22Apr2011 15:58

Pseudocode Tutorial - The Basics
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.


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;
        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++)
    return 0;

Now let us convert the above program into pseudocode using syntax from the following pseudocode guide

Input Variable num
IF num is less than 1 THEN
        Display Error Message
        Exit Program
FOR i = 1 to num step 1 DO
        FOR k = 1 to i step 1 DO
                Display *
        Display linebreak

Final Thoughts

I have tried to explain the basics of Pseudocode but if you have more questions, post them in comments below.

lionaneesh 23Apr2011 22:05

Re: Pseudocode Tutorial - The Basics
Short but effective!!

Nice work Sir!!

shabbir 23Apr2011 22:56

Re: Pseudocode Tutorial - The Basics
Thanks. :D

All times are GMT +5.5. The time now is 04:05.