basics

Syntax Rules & Pseudocode


Programming languages are a lot like human languages in that they have syntax rules.These rules dictate the appropriate arrangements of words, punctuation, and other symbols that form valid statements in the language. For example, in many programming languages, commands or statements are terminated by semicolons (just as most sentences are ended with a period). This is an example of “punctuation” in a programming language.

In English paragraphs are separated by lines, in programming languages blocks of code are separated by curly brackets. Variables are comparable to nouns and operations and functions are comparable to verbs. Complex documents often have footnotes that provide additional explanations; code has comments that provide documentation and explanation for important elements. English is read top-to-bottom, left-to-right.

Programming languages are similar: individual executable commands are written one per line. When a program executes, each command executes one after the other, top-to-bottom.

This is known as sequential control flow. A block of code is a section of code that has been logically grouped together. Many languages allow you to define a block by enclosing the grouped code around opening and closing curly brackets. Blocks can be nested within each other to form sub-blocks.

Most languages also have reserved words and symbols that have special meaning. For example, many languages assign special meaning to keywords such as for , if , while , etc. that are used to define various control structures such as conditionals and loops. Special symbols include operators such as + and * for performing basic arithmetic. Failure to adhere to the syntax rules of a particular language will lead to bugs and programs that fail to compile and/or run.


 Natural languages such as English are very forgiving: we can generally discern what someone is trying to say even if they speak in broken English (to a point). However, a compiler or interpreter isn’t as smart as a human. Even a small syntax error (an error in the source code that does not conform to the language’s rules) will cause a compiler to completely fail to understand the code you have written.


Learning a programming language is a lot like learning a new spoken language (but, fortunately a lot easier).  Good pseudocode makes use of plain English and mathematical notation, making it more readable and abstract.


A small example can be found in Algorithm .


The Pseudocode is very clear unlike flowcharts. It is more individualistic, hence use the following rules for writing Pseudocode.
* Write one statement per line.
* Capitalize initial keywords.
* Indent to show hierarchy.
* End multiline structure.
* Keep statements language independent.

Leave a Reply

Your email address will not be published. Required fields are marked *