Knowledge Base

Pseudocode

Psuedocode is a common practice used by good programmers to plan out their code.

It is a notation or a method of writing down programming concepts in plain language rather than in code syntax.

In practice, programs written out in pseudocode look a lot like recipes!
You've probably seen pseudocode more often than you think.
Check out this pseudocode for making an omelette:

  1. Crack and beat eggs in a bowl.
  2. Grease a frying pan and turn on the stove.
  3. Pour eggs into frying pan.
  4. Fry eggs until solid.
  5. Flip omelette.
  6. Fry until done.

Pseudocode provides the structure or outline of your code. Note that the above pseudocode includes the ingredients and the process, but omits specific measurements. How many eggs? How long should we fry the eggs for? What size frying pan should we choose, and how high should we turn on the heat?

Pseudocode for a very basic program to drive the robot straight and turn right could be as follows:

  1. Drive straight for 3 seconds (or 3 meters).
  2. Turn 90° to the right.
  3. Stop driving.

You can write out this pseudocode on paper before you begin to add blocks in the CoderZ Code Editor.

What might the pseudocode be for driving the robot in the shape of a square? What about pseudocode involving sensors?

Once you have your pseudocode, it makes it much easier to start writing your program.

Was this article helpful?
2 out of 2 found this helpful

Comments

  • Avatar
    JACK MURRAY

    You can cook with pseudo code.

    0
    Comment actions Permalink
  • Avatar
    ELIAS HENRY

    The article was helpful because it simplified the process by step by step instructions on how to plan out your code.

    1
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk