# Pseudocode Tutorial - The Basics

Discussion in 'Programming' started by shabbir, Apr 22, 2011.

Tags:
1. ### shabbirAdministratorStaff Member

Joined:
Jul 12, 2004
Messages:
15,285
364
Trophy Points:
83
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:
```#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.

2. ### lionaneeshActive Member

Joined:
Mar 21, 2010
Messages:
848
224
Trophy Points:
43
Occupation:
Student
Location:
India
Short but effective!!

Nice work Sir!!

Joined:
Jul 12, 2004
Messages:
15,285