# pseudocode!

## Recommended Posts

Pseudocode is writing steps in English? I'm kinda mixed up by some of this. I found an example that confuses me:

Pseudocode to me would be just write simple steps in English. Like for example:

wake up,
get a shower,
get dressed,
have something to eat,
etc, etc.

##### Share on other sites
epicpunnum    459

As this is filed under C++, I'd assume for this case a C-like syntax would be ideal. Personally, like cr88192, I prefer such a syntax as well, especially as C-based laguages have a lot of ground in today's world, encompassing C, C++, C# and Java (not to mention that there are a few other languages that have somewhat similar structures and syntax).

Just for a general idea, psuedocode can have any loosely defined structure. If you wish to adhere more to the language you're using, it could show up as

void performMorningRoutine(){
wakeUp()
shower()
getDressed()
eat(breakfast)
}


In many cases of psuedocode, the actual implementation is ignored, and instead just has a loose design, opting for comments in some places

void eat( food ){
if ( hasFood )
while (hungy){
//decide how to eat your food and eat it.

}
}


In most cases, it's just to give you an idea of the structure you need to follow for an algorithm.
Honestly though, as long as your structure follows some sort of structure that programmers can get, you should be fine. If there's one language you're using specifically, using it's syntax loosely is probably preferred as long as it promotes readability.

##### Share on other sites
alnite    3438

I find it strange that some people would write their pseudocode almost like they are writing actual code.  IMO, if you have to worry about syntax, then might as well write the code. My pseudo-code is usually just plain english mixed with coding symbols, which gets translated into comments, and removed once the code is tested and finalized.

For example,

[tt]

if player's hit points > 0

player runs around

else

player stays, barks, and twirls

[/tt]

Edited by alnite

##### Share on other sites
CC Ricers    1491

I find it strange that some people would write their pseudocode almost like they are writing actual code.  IMO, if you have to worry about syntax, then might as well write the code.

I sometimes find writing pseudocode helpful that way in that it then becomes the first step of a TDD cycle. I'm not heavy on TDD but it has gotten me to write some of my functions quicker.

##### Share on other sites
swiftcoder    18437
The first time you try and write 30 curly braces on a whiteboard during an exam/interview, you'll be cured of adding excessive syntax to your pseudocode.

I tend to stick with a very minimalist style (somewhat pythonic, I guess): indentation indicates scope, statements are plain english plus various mathematical operators.

main:
for each line in input file
calculate running average of columns 2,3
output final averages

##### Share on other sites
spiralseven    132

I use the #typedef function to create psuedo-code prototypes....

##### Share on other sites
spiralseven    132

youre practically giving a label to a complicated set of instruction that would make it appear as if it were english

##### Share on other sites

Thanks for the feedback. Seems there are many ways to use Pseudocode and I understand it now.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account