Introduction to Programming/Organization
How is a program organized and used? [part 1][edit | edit source]
A simple program is a list of statements. When the program is invoked, the computer starts at the beginning of the list and executes each statement in order until it reaches the end. Then it stops. The exact form of a program, where the "first statement" is located as well as what can be done in a statement are all determined by the programming language being used.
From here on, this learning activity will be covering all material that should be reinforced through actual programming exercises. If you have not yet selected a programming language, please do that now and do the first lesson. This lesson will usually introduce a minimalistic program known as Hello, world!. Though seemingly meaningless, this lesson is nevertheless important because it gives students three critical skills—editing a source file, compiling the source file (if it is a compiled language) and running the resulting program.
- Break to do the first programming exercise
Statements[edit | edit source]
Most computer programming languages have statements or something similar to them. The terms line and line of code are also used.
A statement is a more-or-less atomic piece of code that is clearly differentiated, usually by a special character or character sequence called a statement terminator.
In C (and languages like C such as C++, Java, etc.) the statement terminator is a semi-colon (;). In BASIC (and languages like BASIC such as Fortran, Ruby, Python, etc.) the statement terminator is a newline. In Prolog and Erlang the statement terminator is a period (.).
this could be a statement; this would be another statement;
The syntax rules for statements are very rigid and ruthlessly enforced by the compiler/interpreter. Inexperienced programmers sometimes miss subtle nuances in programming language rules, causing them no end of trouble. When learning a new programming language, you should have access to an experienced programmer who can help you with these kinds of problems.