How to write pseudocode pdf




















Expert Columnist. June 23, Updated: November 9, Join the Expert Contributor Network. How to Write Pseudocode Always capitalize the initial word often one of the main six constructs. Only one statement per line. Indent to show hierarchy, improve readability, and show nested constructs.

Keep your statements programming language independent. Use the naming domain of the problem, not that of the implementation. Why Use Pseudocode? Better Readability: Often, programmers work alongside people from other fields such as mathematicians, managers and business partners. Using pseudocode to explain the mechanics of the code makes communicating between different specialties easier and more efficient. Eases Up Code Construction: When the programmer goes through the process of developing and generating pseudocode converting that into real code written in any programming language will become much easier and faster.

A Good Middle Point Between Flowchart and Code: Moving directly from the idea to the flowchart to the code is not always a smooth ride.

Acts as a Starting Point for Documentation: Documentation is an essential aspect of building a good project but starting documentation is often the most difficult part of the process. Pseudocode can represent a good starting point for what the documentation should include.

Sometimes, programmers even include the pseudocode as a docstring at the beginning of the code file. Easier Bug Detection: Since pseudocode is written in a human-readable format, it is easier to edit and discover bugs before actually writing a single line of code. We can edit pseudocode more efficiently than testing, debugging and fixing actual code. Data Science. Software Engineering Perspectives. Learn More. Yes No. Log in Social login does not work in incognito and private browsers.

Please log in with your username or email to continue. No account yet? Create an account. Edit this Article. We use cookies to make wikiHow great. By using our site, you agree to our cookie policy. Cookie Settings. Learn why people trust wikiHow. Download Article Explore this Article parts. Tips and Warnings. Related Articles. Article Summary. Part 1. Know what pseudocode is. Pseudocode is a step-by-step written outline of your code that you can gradually transcribe into the programming language.

Many programmers use it to plan out the function of an algorithm before setting themselves to the more technical task of coding. Understand why pseudocode is useful. Pseudocode is used to show how a computing algorithm should work. Coders often use pseudocode as an intermediate step in programming in between the initial planning stage and the stage of writing actual executable code. Some other uses of pseudocode include the following: Describing how an algorithm should work.

Pseudocode can illustrate where a particular construct, mechanism, or technique could or must appear in a program. Explaining a computing process to less-technical users. Computers need a very strict input syntax to run a program, but humans especially non-programmers may find it easier to understand a more fluid, subjective language that clearly states the purpose of each line of code.

Designing code in a group setting. High-level software architects will often include pseudocode into their designs to help solve a complex problem they see their programmers running into. If you are developing a program along with other coders, you may find that pseudocode helps make your intentions clear.

Remember that pseudocode is subjective and nonstandard. There is no set syntax that you absolutely must use for pseudocode, but it is a common professional courtesy to use standard pseudocode structures that other programmers can easily understand.

If you are working with others on a project—whether they are your peers, junior programmers, or non-technical collaborators—it is important to use at least some standard structures so that everyone else can easily understand your intent.

If you are enrolled in a programming course at a university, a coding camp, or a company, you will likely be tested against a taught pseudocode "standard". This standard often varies between institutions and teachers. Focus on the main purpose of pseudocode. It can be easy to revert to writing in code once you hit your stride.

Remembering the purpose of your pseudocode—explaining what each line of the program should do—will keep you grounded while creating the pseudocode document. Part 2. Use a plain-text editor.

It can be tempting to use a word processor e. Start by writing down the purpose of the process. Dedicating a line or two to explaining the purpose of your code will help set up the rest of the document, and it will also save you the task of explaining the program's function to each person to whom you show the pseudocode.

Each statement in your pseudocode should express just one action for the computer. In most cases, if the task list is properly drawn, then each task will correspond to one line of pseudocode.

Consider writing out your task list, then translating that list into pseudocode, then gradually developing that pseudocode into actual, computer-readable code. Use white space and indentation effectively. Using white spaces between "blocks" of text will help keep different components of your pseudocode isolated, and indenting different pieces of each block will indicate that those pieces of pseudocode go under a less-indented section.

For example, a section of pseudocode that discusses entering a number should all be in the same "block", while the next section e. Capitalize key commands if necessary. Depending on your pseudocode requirements or the environment in which you're publishing the pseudocode, you may need to capitalize commands that will remain in the actual code.

For example, if you use "if" and "then" commands in your pseudocode, you might want to change them to read "IF" and "THEN" e.

Write using simple terminology. Remember, you're writing about what the project will do , not summarizing the code itself. This is especially important if you're writing pseudocode to serve as a demonstration for a customer who doesn't know coding, or as a project for a beginner programmer.

Keep your pseudocode in the proper order. While the language you use to modify your pseudocode should be simple, you still need to keep each piece of your pseudocode in the order in which it needs to be executed. Leave nothing to the imagination. Everything that is happening in the process must be described completely. Pseudocode statements are close to simple English statements.

Pseudocode does not typically use variables, but instead describes what the program should do with close-to-real-world objects such as account numbers, names, or transaction amounts. Even if there is no standard for pseudocode, it will be easier for other programmers to understand your steps if you use structures from existing sequential programming languages. Organize your pseudocode sections. If you have large sections of pseudocode that define other pieces of pseudocode within the same block, you may want to use brackets or other identifiers to keep everything contained.

Brackets—both standard e. You can use this same method when writing pseudocode to leave notes that don't fit into the coding text. Double-check your pseudocode for readability and clarity. You should be able to answer the following questions by the end of the document: Would this pseudocode be understood by someone who isn't familiar with the process?

Is the pseudocode written in such a way that it will be easy to translated it into a computing language? Does the pseudocode describe the complete process without leaving anything out? Is every object name used in the pseudocode clearly understood by the target audience? If you find that a section of pseudocode needs elaboration or it doesn't explicitly outline a step that someone else might forget, go back and add the necessary information.

Part 3. Open a plain-text editor. Define your program. While not strictly necessary, writing a one- or two-sentence line at the top of the document will make clear from the beginning the intent of the program: This program will request a greeting from the user. If the greeting matches a specific response, the response will be delivered ; if not, a rejection will be delivered. Write the opening sequence. Your first command—that is, the first thing your program should do upon running—should be the first line: print greeting "Hello stranger!

Add the next line. Add the call to action. In this example, the user will be prompted for a greeting: print call-to-action "How are you? Show the user a list of responses. Not good. Request input from the user.

This is where the program will ask the user to enter a response: print request for input "Enter the number that best describes you:". Create "if" commands for the user's input. Since there are multiple responses the user can select, you'll want to add multiple results based on their selected response: if "1" print response "Dandy! Add an error message. In the event that the user incorrectly chooses a response, you can have an error message ready: if input isn 't recognized print response "You don' t follow instructions very well, do you?



0コメント

  • 1000 / 1000