You are viewing the article How to Write Pseudocode at Lassho.edu.vn you can quickly access the necessary information in the table of contents of the article below.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 37,519 times.
This wikiHow teaches you how to write pseudocode text for your computer programs. Simply put, pseudo-coding is creating a non-programming language script that states the intent of your code.
Steps
Master the fundamentals of pseudocode
Pseudocode serves as an informal guide, a tool to help brainstorm program solutions, and also a communication tool that can help you present your ideas. with others.
- Describe how the algorithm will work. Pseudocode can illustrate that a certain constructor, mechanism, or technique can or is required to appear somewhere in the program.
- Explain computing processes to less qualified users. Computers need extremely strict input syntax to run programs, but humans (especially non-programmers) may find it easier to learn a flexible language, coherent, showing the purpose of each line of code.
- Design code for the whole team. Highly qualified software engineers often insert pseudocode into their designs to aid in solving complex problems they find many of their programmers are facing. If you’re developing a program with other coders, you may find that pseudocode makes your intentions clearer.
- If you’re collaborating with others on the same project—whether it’s a colleague, junior developer, or non-technical collaborator—it’s important that you use at least some standard structure so people can easily understand your intentions.
- If you’re taking a coding course at a university, coding camp, or company, you’ll likely have to take a test on the pseudocode “standard” you’ve been taught. This standard will often vary depending on the institution and the teacher.
Transparency is the primary goal of pseudocode, which can be helpful if you work by accepted programming conventions. When developing pseudocode into real code, you need to convert the pseudocode into a programming language – so it can help you shape the sketch in your head.
Write good pseudocode
Plain text editors include Notepad (on Windows) and TextEdit (on Mac).
- For example, the part of pseudocode that talks about entering numbers should be in the same “block”, and the part that follows (such as the part that talks about results) should be in another block.
- Example: If you use the “if” and “then” keywords in your pseudocode, you may want to capitalize “IF” and “THEN”, such as “IF input number THEN output result” (IF enter THEN number of outputs).
You may even want to get rid of all the code statements and just define each line in plain language. Example: Instead of writing “if input is odd, output ‘Y'” (if input is odd, output is ‘Y’) write “if user enters an odd number, display ‘Y'” (if user enters an odd number, display ‘Y'” enter odd number, display ‘Y’).
- if CONDITION then INSTRUCTION — Means the statement will only be executed if a certain condition is true. “Instruction” in this case is a step that the program will perform, and “condition” means that the data must satisfy a certain condition for the program to perform the action.
- while CONDITION do INSTRUCTION — Means the statement will be executed repeatedly until the condition is no longer true.
- do INSTRUCTION while CONDITION — Very similar to “while CONDITION do INSTRUCTION”. In this case, the condition will be checked before executing the statement, and in the other case, the statement will be executed first. Thus, then the statement will be executed at least once.
- function NAME (ARGUMENTS): INSTRUCTION — That is, every time a name is used in the code, it will replace a specific statement. “Arguments” is a list of variables that you can use to clarify the statement.
- Brackets—including standard square brackets (such as [code]) and curly braces (such as {code})—can help include long pseudocode.
- When coding, you can add comments by typing “//” to the left of the comment line (eg
//Đây là bước tạm thời.
). You can use this method when writing pseudocode to write comments that cannot be included in the code.
- Can someone who doesn’t know this statement understand your pseudocode?
- Is the pseudocode properly written to be easily converted into a programming language?
- Did the pseudocode describe the complete statement, leaving nothing out?
- Will others clearly understand each object name used in the pseudocode?
- If you notice that a part of your pseudocode needs to be modified or haven’t specified a step that others might forget, you need to go back and add the necessary information.
Example of generating pseudocode text
This program will ask for the option to choose from the user. If that option matches, the response will be displayed ; If not, a message will be displayed.
print greeting ( print greeting ) "Hello stranger!" ( Hi there! )
print prompt ( print dialog box )
press "Enter" to continue ( press "Enter" to continue )
<user presses "Enter" >
print call-to - action "How are you?" ( How are you? )
display possible responses "1. Fine." ( strong ) "2. Great!" ( very strong ! ) "3. Not good." ( unwell )
print request for input " Enter the number that best describes you:" ( enter the number that best describes you )
if "1" ( if "1" is selected )
print response "Dandy! " ( If you choose "2" ) if "2" ( if you choose "2" )
print response "Fantastic! " ( Very strong is great ! ) if "3" ( if "3" is selected )
print response "Lighten up, buttercup !" ( Relax a little to be healthy, my friend! )
if input isn 't recognized (if the user's response is not recognized) print response "You don't fplow instructions very well, do you? " (You have not followed the instructions correctly. Are not?)
This program requires the user to enter a number. If the number matches the available answer, the answer will be displayed ; If not, a message will be displayed.
print greetings
"Hello!"
print dialog
Press "Enter" to continue
<After the user presses "Enter" >
Print inquiry and call to action
"How are you today?"
display selectable answer options
"1. Fine." "2. Very strong!" "3. Unwell."
print requires input
"Enter the number that best suits you:" if enter "1"
print the answer
"It's good to be fine!" if enter "2"
print the answer
"Very good is very good!" if enter "3"
print the answer
"Relax for a while, my friend!" if cannot recognize user input
print the answer
"Didn't you follow the instructions properly?"
Advice
- Pseudocode is optimal for complex programs that are hundreds to thousands of lines in length.
Warning
- Pseudocode is no substitute for real code when creating a program. Pseudocode can only be used to generate reference text to know what the code does.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 37,519 times.
This wikiHow teaches you how to write pseudocode text for your computer programs. Simply put, pseudo-coding is creating a non-programming language script that states the intent of your code.
Thank you for reading this post How to Write Pseudocode at Lassho.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: