Skip to main content
X

Explore your training options in 10 minutes

Coding

What is Pseudocode?

James Gallagher - March 29, 2021


Developers usually do not start writing code immediately after a big assignment. The issue with this approach is that the developer will have to think about how they go about completing the assignment as they go. In many cases, it is better to think about what logic will go into their program before they start coding.

That’s where pseudocode is useful. Pseudocode is a method of outlining and describing code you plan to write. Pseudocode helps developers develop a strategy for building a program or an algorithm before they start writing actual code.

This tutorial covers what pseudocode is, where you might see pseudocode, and how to write your own pseudocode programs.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses










By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

What is Pseudocode?

Pseudocode is not a programming language in itself. Rather, pseudocode is a human expression of what you plan to write in code. You can use words or symbols to represent pseudocode, but the key to good pseudocode is to be as clear as possible about how you want your program to work.

When is Pseudocode Used?

Pseudocode is a part of many computer science curricula. This is because pseudocode often comes up often in software development.

Consider the following scenario: Your boss has asked you to implement a bubble sorting algorithm in a program your company uses. This program must function because the program is an essential part of your company’s website.

Should a developer rush into their terminal and code together a solution? In a case like this, where the algorithm is business-critical, planning out the steps the developer plans to take may be helpful.

Of course, a lot of coding is done without writing pseudocode first. Pseudocode is best for planning out more complex programs or changes to programs. You may also write pseudocode if multiple people will be building a piece of software to make sure everyone understands how their code contributes to the final deliverable (the finished program).

If you are confused about how to write some code, you may scribble down some notes on how you want your code to work. This will give you a point of reference to which you can refer during your coding. Such a point of reference means you do not need to keep everything related to your program in your mind while you are coding.

How Do You Write Pseudocode?

Pseudocode has no specific symbols or words you must use to outline your programs. This is because pseudocode can represent how you plan to implement a program in any language. If pseudocode was written in a certain way, developers could easily get confused between the code written in pseudocode and their real-world programs.

To write good pseudocode, you need to be clear. You should also distinguish between program text and other text. For instance, you may capitalize all operations like loops and use lower case for variable names and text in a string.

Consider this example:

DECLARE students

FOR s IN ALL students
	IF LENGTH s > 5:
		PRINT s

This is a simple example of a good pseudocode. Our example is easy to read. You can see that we first want to declare an object called students. Then we want to iterate over each of them using a for statement (or whatever iterator is appropriate). We use an if statement to check if the length of each student is greater than 5.

Any student whose name contains more than five letters needs to be printed to the console.

Venus, a software engineer at Rockbot

"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"

Venus, Software Engineer at Rockbot

Now consider this pseudocode:

PRINT students > 5

This code is confusing. It is unclear what we are trying to say. Whereas in our last example we are clear on declaring a variable for students. Our last example also clearly states exactly what text we want to print to the console.

Pseudocode Examples

To write good pseudocode, you may draw on some words with which you are familiar from the programming languages you use. Words like:

  • If
  • Else
  • Declare
  • Remove
  • Add
  • Return
  • Print

These are all words you could use in pseudocode. But as we said earlier, there are no strict rules on exactly what terminology you should use. Consider this example:

INPUT "What is your name?" STORE AS name
DECLARE user_len = LENGTH name

PRINT user_len

This pseudocode represents a program that asks a user for their name and displays how many characters are in that name to the console.

You can use pseudocode to express more complicated operations in a simple way:

CREATE CLASS bank_account
	balance FLOAT DEFAULT 0
	name STRING REQUIRED
	
DECLARE ACCOUNT AS john_doe WITH name "John"
SET john_doe balance TO 100

This code shows declaring a class. Declaring a class and creating an object of that class would usually use up more lines that we have used in our pseudocode. In this example, we abstract away from the specifics of declaring a class in a language. Instead we say “CREATE CLASS” and then outline how our class should be structured.

Conclusion

Pseudocode is a way of representing code you plan to write before you start writing the code. You can use any words to describe your code in pseudocode. The aim of pseudocode is to make you think about how you want your program to work before you start coding. You can share your pseudocode with others to get their feedback, too.

Now you have the knowledge you need to write pseudocode like a professional coder.

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

James Gallagher

About the author: James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others. He also serves as a researcher at Career Karma, publishing comprehensive reports on the bootcamp market.

Skip to main content