Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Pseudocode
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Syntax== Pseudocode generally does not actually obey the [[syntax]] rules of any particular language; there is no systematic standard form. Some writers borrow style and syntax from control structures from some conventional programming language, although this is discouraged.<ref>{{cite book|title=Code Complete|title-link=Code Complete|page=54 |quote=Avoid syntactic elements from the target programming language|first1=Steve|last1=McConnell|authorlink=Steve McConnell|isbn=978-0-7356-1967-8 |date=2004|publisher=Pearson Education }}</ref><ref>Invitation to Computer Science, 8th Edition by Schneider/[[Judith Gersting|Gersting]], "Keep statements language independent" as quoted [https://cs.stackexchange.com/questions/97851/writing-pseudocode-to-be-language-independent in this stackexchange question]</ref> Some syntax sources include [[Fortran]], [[Pascal (programming language)|Pascal]], [[BASIC]], [[C (programming language)|C]], [[C++]], [[Java (programming language)|Java]], [[Lisp (programming language)|Lisp]], and [[ALGOL]]. Variable declarations are typically omitted. Function calls and blocks of code, such as code contained within a loop, are often replaced by a one-line natural language sentence. Depending on the writer, pseudocode may therefore vary widely in style, from a near-exact imitation of a real programming language at one extreme, to a description approaching formatted prose at the other. This flexibility brings both major advantages and drawbacks: on the positive side, no executable programming language "can beat the convenience of inventing new constructs as needed and letting the reader try to deduce their meaning from informal explanations", on the negative, "untested code is usually incorrect".<ref>{{cite web |last1=Lamport |first1=Leslie |url=https://www.microsoft.com/en-us/research/uploads/prod/2016/12/The-PlusCal-Algorithm-Language.pdf |publisher=Microsoft Research |access-date=28 May 2024 | title = The PlusCal Algorithm Language |date=2 January 2009}}</ref> {| class="wikitable" |+ An example of pseudocode (for the [[mathematical game]] [[fizz buzz]]) |-valign="top" || Pascal style: <syntaxhighlight lang="Pascal" style="font-size:85%"> procedure fizzbuzz; for i := 1 to 100 do print_number := true; if i is divisible by 3 then begin print "Fizz"; print_number := false; end; if i is divisible by 5 then begin print "Buzz"; print_number := false; end; if print_number, print i; print a newline; end </syntaxhighlight> || C style: <syntaxhighlight lang="C" style="font-size:85%"> fizzbuzz() { for (i = 1; i <= 100; i++) { print_number = true; if (i is divisible by 3) { print "Fizz"; print_number = false; } if (i is divisible by 5) { print "Buzz"; print_number = false; } if (print_number) print i; print a newline; } } </syntaxhighlight> || Python style: <syntaxhighlight lang="Python" style="font-size:85%"> def fizzbuzz(): for i in range(1,101): print_number = true if i is divisible by 3: print "Fizz" print_number = false if i is divisible by 5: print "Buzz" print_number = false if print_number: print i print a newline </syntaxhighlight> |} {{Category see also|Articles with example pseudocode}}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Pseudocode
(section)
Add topic