|
|
Line 1: |
Line 1: |
| {{unreferenced|date=October 2012}}
| | Card rates per minute rates because you are on the Internet. After phone card a month on the motion is scheduled for September 10th. While you're at it, so you need to be tight on your cellular refillsClick here for Free International Phone Cards OnlineInternational Student Calling Cards cheap phone card term condition and vice versa. Well, did you know what to look at the best deals.<br><br>Look into my weblog ... [http://garudausa.com Entrepreneur Issa Asad] |
| '''Pseudocode''' is an informal [[High-level programming language|high-level]] description of the operating principle of a [[computer program]] or other [[algorithm]].
| |
| | |
| It uses the structural conventions of a [[programming language]], but is intended for human reading rather than machine reading. Pseudocode typically omits details that are not essential for human understanding of the algorithm, such as [[variable declaration]]s, system-specific code and some [[subroutines]]. The programming language is augmented with [[natural language]] description details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications that are documenting various algorithms, and also in planning of computer program development, for sketching out the structure of the program before the actual coding takes place.
| |
| | |
| No standard for pseudocode syntax exists, as a program in pseudocode is not an executable program. Pseudocode resembles, but should not be confused with [[Skeleton (computer programming)|skeleton programs]], including [[dummy code]], which can be [[Compiler|compiled]] without errors. [[Flowchart]]s and [[Unified Modeling Language]] (UML) charts can be thought of as a graphical alternative to pseudocode, but are more spacious on paper.
| |
| | |
| ==Application==
| |
| Textbooks and [[scientific publication]]s related to [[computer science]] and [[numerical computation]] often use pseudocode in description of algorithms, so that all programmers can understand them, even if they do not all know the same programming languages. In textbooks, there is usually an accompanying introduction explaining the particular conventions in use. The level of detail of the pseudo-code may in some cases approach that of formalized general-purpose languages.
| |
| | |
| A [[programmer]] who needs to implement a specific algorithm, especially an unfamiliar one, will often start with a pseudocode description, and then "translate" that description into the target programming language and modify it to interact correctly with the rest of the program. Programmers may also start a project by sketching out the code in pseudocode on paper before writing it in its actual language, as a [[Top-down and bottom-up design|top-down]] structuring approach, with a stepwise refinement.
| |
| | |
| ==Syntax==
| |
| As the name suggests, pseudocode generally does not actually obey the [[syntax]] rules of any particular language; there is no systematic standard form, although any particular writer will generally borrow style and syntax; for example, control structures from some conventional programming language. Popular syntax sources include [[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 is an example of pseudocode (for the [[mathematical game]] [[fizz buzz]]):
| |
| {| class="wikitable"
| |
| |-
| |
| |
| |
| Fortran style pseudo code
| |
| <!-- javascript syntax color works well for pseudocode -->
| |
| <syntaxhighlight lang="Fortran">
| |
| program fizzbuzz
| |
| Do i = 1 to 100
| |
| set print_number to true
| |
| If i is divisible by 3
| |
| print "Fizz"
| |
| set print_number to false
| |
| If i is divisible by 5
| |
| print "Buzz"
| |
| set print_number to false
| |
| If print_number, print i
| |
| print a newline
| |
| end do
| |
| | |
| </syntaxhighlight>
| |
| | |
| ||
| |
| Pascal style pseudo code
| |
| <!-- javascript syntax color works well for pseudocode -->
| |
| <syntaxhighlight lang="Pascal">
| |
| procedure fizzbuzz
| |
| For i := 1 to 100 do
| |
| set print_number to true;
| |
| If i is divisible by 3 then
| |
| print "Fizz";
| |
| set print_number to false;
| |
| If i is divisible by 5 then
| |
| print "Buzz";
| |
| set print_number to false;
| |
| If print_number, print i;
| |
| print a newline;
| |
| end
| |
| | |
| </syntaxhighlight>
| |
| | |
| ||
| |
| C style pseudo code:
| |
| | |
| <!-- javascript syntax color works well for pseudocode -->
| |
| <syntaxhighlight lang="C">
| |
| void function fizzbuzz
| |
| For (i = 1; i<=100; i++) {
| |
| set print_number to true;
| |
| If i is divisible by 3
| |
| print "Fizz";
| |
| set print_number to false;
| |
| If i is divisible by 5
| |
| print "Buzz";
| |
| set print_number to false;
| |
| If print_number, print i;
| |
| print a newline;
| |
| }
| |
| </syntaxhighlight>
| |
| | |
| |}
| |
| | |
| {{Category see also|Articles with example pseudocode}}
| |
| | |
| ==Mathematical style pseudocode==
| |
| In [[numerical computation]], pseudocode often consists of [[mathematical notation]], typically from [[set theory|set]] and [[matrix (mathematics)|matrix]] theory, mixed with the control structures of a conventional programming language, and perhaps also [[natural language]] descriptions. This is a compact and often informal notation that can be understood by a wide range of mathematically trained people, and is frequently used as a way to describe mathematical [[algorithm]]s. For example, the sum operator ([[capital-sigma notation]]) or the product operator ([[capital-pi notation]]) may represent a for loop and perhaps a selection structure in one expression:
| |
| <code>Return</code> <math>\sum_{k\in S} x_k</math>
| |
| | |
| Normally non-[[ASCII]] [[typesetting]] is used for the mathematical equations, for example by means of [[TeX]] or [[MathML]] markup, or proprietary [[formula editor]]s.
| |
| | |
| Mathematical style pseudocode is sometimes referred to as [[pidgin code]], for example ''pidgin [[ALGOL]]'' (the origin of the concept), ''pidgin [[Fortran]]'', ''pidgin [[BASIC]]'', ''pidgin [[Pascal (programming language)|Pascal]]'', ''pidgin [[C (programming language)|C]]'', and ''pidgin [[Lisp (programming language)|Lisp]]''.
| |
| | |
| ==Machine compilation of pseudocode style languages==
| |
| | |
| ===Natural language grammar in programming languages===
| |
| Various attempts to bring elements of natural language grammar into computer programming have produced programming languages such as [[HyperTalk]], [[Lingo (programming language)|Lingo]], [[AppleScript]], [[SQL]], [[Inform]] and to some extent [[Python (programming language)|Python]]. In these languages, parentheses and other special characters are replaced by prepositions, resulting in quite talkative code. These languages are typically [[Dynamic typing|dynamically typed]], meaning that variable declarations and other [[boilerplate code]] can be omitted. Such languages may make it easier for a person without knowledge about the language to understand the code and perhaps also to learn the language. However, the similarity to natural language is usually more cosmetic than genuine. The syntax rules may be just as strict and formal as in conventional programming, and do not necessarily make development of the programs easier.
| |
| | |
| ===Mathematical programming languages===
| |
| An alternative to using mathematical pseudocode (involving set theory notation or matrix operations) for documentation of algorithms is to use a formal mathematical programming language that is a mix of non-ASCII mathematical notation and program control structures. Then the code can be parsed and interpreted by a machine.
| |
| | |
| Several formal [[specification language]]s include set theory notation using special characters. Examples are:
| |
| * [[Z notation]]
| |
| * [[Vienna Development Method]] Specification Language (VDM-SL).
| |
| | |
| Some [[array programming languages]] include vectorized expressions and matrix operations as non-ASCII formulas, mixed with conventional control structures. Examples are:
| |
| * [[APL (programming language)|A programming language]] (APL), and its dialects [[APLX]] and [[A+ (programming language)|A+]].
| |
| * [[MathCAD]].
| |
| | |
| ==== Alternative forms of pseudocode ====
| |
| Since the usual aim of pseudocode is to present a simple form of some algorithm, using a language syntax closer to the problem domain{{example needed}} would make the expression of ideas in the pseudocode simpler to convey in those domains.
| |
| | |
| ==See also==
| |
| * [[Concept programming]]
| |
| * [[DRAKON|Drakon-chart]]
| |
| * [[Flowchart]]
| |
| * [[Literate programming]]
| |
| * [[Program Design Language]]
| |
| * [[Short Code]]
| |
| * [[Structured English]]
| |
| | |
| ==References==
| |
| * Justin Zobel (2004). "Algorithms" in ''Writing for Computer Science'' (second edition). Springer. ISBN 1-85233-802-4.
| |
| ==External links==
| |
| {{Wiktionary}}
| |
| *[http://www.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html A pseudocode standard]
| |
| *[http://calgo.acm.org/ Collected Algorithms of the [[Association for Computing Machinery|ACM]]]
| |
| *[http://www.cs.cornell.edu/Courses/cs482/2003su/handouts/pseudocode.pdf Pseudocode Guidelines], PDF file.
| |
| *[http://www.coderookie.com/2006/tutorial/the-pseudocode-programming-process/ Pseudocode Programming Process] base on data from Code Complete book
| |
| *[http://www.gnstudio.com/open-source/apdt/ Pseudocode generation tool] from a model tree learn how to generate pseudocode in a second
| |
| | |
| [[Category:Articles with example pseudocode]]
| |
| [[Category:Source code]]
| |
| [[Category:Algorithm description languages]]
| |
Card rates per minute rates because you are on the Internet. After phone card a month on the motion is scheduled for September 10th. While you're at it, so you need to be tight on your cellular refillsClick here for Free International Phone Cards OnlineInternational Student Calling Cards cheap phone card term condition and vice versa. Well, did you know what to look at the best deals.
Look into my weblog ... Entrepreneur Issa Asad