How do I write a psuedocode?

This is for an introduction to programming class.that I'm taking and I'm having a little bit of a hard time learning this.

Comments

  • Pseudocode (derived from pseudo and code) is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of programming languages, but omits detailed subroutines, variable declarations or language-specific syntax. The programming language is augmented with natural language descriptions of the details, where convenient.

    Pseudocode resembles, but should not be confused with, skeleton programs including dummy code, which can be compiled without errors. Flowcharts can be thought of as a graphical form of pseudocode.

    Contents [hide]

    1 Syntax

    2 Application

    3 Examples of pseudocode

    4 Mathematical style pseudocode

    5 Machine compilation or interpretation

    5.1 Natural language grammar in programming languages

    5.2 Mathematical programming languages

    6 Instances in popular culture

    7 See also

    8 External links

    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 the appearance of a particular language. Popular sources include PASCAL, C, Java, BASIC, Lisp, and ALGOL. Details not relevant to the algorithm (such as memory management code) are usually omitted. Blocks of code, for example code contained within a loop, may be described in 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.

    Application

    Textbooks and scientific publications 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 such languages may in some cases approach that of formalized general-purpose languages — for example, Knuth's seminal textbook The Art of Computer Programming describes algorithms in a fully-specified assembly language for a non-existent microprocessor.

    A programmer who needs to implement a specific algorithm, especially an unfamiliar one, will often start with a pseudocode description, and then simply "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 structuring approach.

    [edit] Examples of pseudocode

    An example of how pseudocode differs from regular code is below.

    Regular code (written in PHP):

    <?php

    if (is_valid($cc_number)) {

    execute_transaction($cc_number, $order);

    } else {

    show_failure();

    }

    ?>

    Pseudocode:

    if credit card number is valid

    execute transaction based on number and order

    else

    show a generic failure message

    end if

    Mathematical style pseudocode

    In numerical computation, pseudocode often consists of mathematical notation, typically from set and 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 algorithms.

    Normally non-ascii typesetting is used for the mathematical equations, for example by means of TeX or MathML markup, or proprietory Formula editor formats.

    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, and pidgin C.

    Machine compilation or interpretation

    It is often suggested that future programming languages will be more similar to pseudocode or natural language than to present-day languages; the idea is that increasing computer speeds and advances in compiler technology will permit computers to create programs from descriptions of algorithms, instead of requiring the details to be implemented by a human.

    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, AppleScript, SQL and Inform. In these languages, parentheses and other special characters are replaced by prepositions, resulting in quite talkative code. This 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 are 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 languages include set theory notation using special characters. Examples are:

    Z notation

    VDM specification language

    Some array programming languages include vectorized expressions and matrix operations as non-ascii formulas, mixed with conventional control structures. Examples are:

    A programming language (APL), and its dialects APLX and A+.

    MathCAD.

  • Pseudocode is a step-by-step English description of what you want the program to do.

    It is a loose outline of how you propose to write the actual code. While not an imperative step to writing tight code, it is definitely a useful exercise as you learn to program. If you become a programmer working on a project with several other programmers, psuedocode can be used to help divide the process. When everyone knows what their section of code is supposed to do, they can focus on their task and trust that the others will be able to write code that will work together.

  • pseudocode is "code' not written in the programming language.

    i.e.

    open console application

    position cursor

    write "Hello World" to console application

    pseudocode usualy involves logic which is written dirrectly

    i.e.

    get number from file

    if number > minimum

    blink a red LED

    else if number < minimum

    blink a green LED

    while(button_pressed) //wait here

    The structure of the pseudocode will eventually become the structure of the actual code when variable names have been chosen, programming language is assigned, and compiler has been chosen.

  • Basically you write out in English sentences or phrases the steps you would go through to accomplish the goal of the program.

  • What exactly are you having difficulty with?

  • with a psuedo pencil

  • what is a psuedocode?

Sign In or Register to comment.