Copyright

Pseudocode: Definition & Examples

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Boolean Logic, Operators & Expressions

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
 Replay
Your next lesson will play in 10 seconds
  • 0:00 Defining Pseudocode
  • 0:28 Understanding Pseudocode
  • 1:29 Examples Of Pseudocode
  • 2:59 Basic Guidelines
  • 4:29 Pseudocode Text Editors
  • 5:02 Lesson Summary
Add to Add to Add to

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Login or Sign up

Timeline
Autoplay
Autoplay

Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Alisa Perry

Alisa has taught college Computer Technology and has a master's degree in Computer Science.

Before you write one piece of computer code, you have to know what the program is supposed to do. Before you write one line of code in any language, it is a good idea to write it in a simple way first to ensure you have included everything you need. The best way to set this up is by using pseudocode.

Defining Pseudocode

Pseudocode is a simple way of writing programming code in English. Pseudocode is not actual programming language. It uses short phrases to write code for programs before you actually create it in a specific language. Once you know what the program is about and how it will function, then you can use pseudocode to create statements to achieve the required results for your program.

Understanding Pseudocode

Pseudocode makes creating programs easier. Programs can be complex and long; preparation is the key. For years, flowcharts were used to map out programs before writing one line of code in a language. However, they were difficult to modify and with the advancement of programming languages, it was difficult to display all parts of a program with a flowchart. It is challenging to find a mistake without understanding the complete flow of a program. That is where pseudocode becomes more appealing.

To use pseudocode, all you do is write what you want your program to say in English. Pseudocode allows you to translate your statements into any language because there are no special commands and it is not standardized. Writing out programs before you code can enable you to better organize and see where you may have left out needed parts in your programs. All you have to do is write it out in your own words in short statements. Let's look at some examples.

Examples of Pseudocode

Let's review an example of pseudocode to create a program to add 2 numbers together and then display the result.

Start Program
Enter two numbers, A, B
Add the numbers together
Print Sum
End Program

Compare that pseudocode to an example of a flowchart to add two numbers

Now, let's look at a few more simple examples of pseudocode. Here is a pseudocode to compute the area of a rectangle:

Get the length, l, and width, w
Compute the area = l*w
Display the area

Now, let's look at an example of pseudocode to compute the perimeter of a rectangle:

Enter length, l
Enter width, w
Compute Perimeter = 2*l + 2*w
Display Perimeter of a rectangle

Remember, writing basic pseudocode is not like writing an actual coding language. It cannot be compiled or run like a regular program. Pseudocode can be written how you want. But some companies use specific pseudocode syntax to keep everyone in the company on the same page. Syntax is a set of rules on how to use and organize statements in a programming language. By adhering to specific syntax, everyone in the company can read and understand the flow of a program. This becomes cost effective and there is less time spent finding and correcting errors.

Basic Guidelines

If you would like a format for using pseudocode to create your program, here are some basic guidelines:

First, do not use language-specific commands in your statements. Pseudocode should be universal. So when creating the task list, you would not include commands that are for any specific language like C++, Java, C#, or Perl. The point of pseudocode is to design a program that can be translated into any language.

Second, remember to write only one task or statement per line. Make sure you put only one task on each line. Including too much information on one line can be confusing and increases the possibility of errors.

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 160 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create An Account
Support