Struttura di un programma Estrutura de um programa Programmstruktur Structure d'un programme Estructura de programa

How does a computer program work?

A program's behaviour depends on the type of language used to write the program.

Nonetheless, almost all programming languages are based upon the same principle:
The program consists of a set of commands that the computer must execute. The computer executes the commands as it reads the file (from top to bottom) until it reaches a command (often referred to as a branch command) which tells the computer to go to a specific location in the program. In a way it resembles a treasure hunt where the computer must follow the clues and execute commands until it reaches the end of the program and is stopped.

The concept of variables

Variables are used in most languages, where a name is associated with content. For example, we can call a variable "dummy" and assign it the value 8.

Data types

Some languages allow you to associate any data type to a variable (either a whole number or a character), such a language is called a non-typed language.
As can be seen in the chapter data representation, the type of data sets the number of bytes that the data is coded in, i.e. the amount of memory that this data takes up as well as the format in which it is represented.
For this reason evolved languages (C, Java) are typed languages, meaning that a variable is not only associated with a name but also a data type, which should be specified when declaring the variable, i.e. when the variable name is written for the first time you must specify in the compiler the type of data this variable will contain (the method of declaring the variable depends on the language used).

Syntax

Programming languages require strict syntax, you cannot simply write things as you wish.

Thus, some languages are case sensitive, meaning that a name written in lower case is not considered to be the equivalent of the same name written in upper case. So the variable "Dummy" is different to the variable "dummy".

Variable names usually require a maximum length (depending on the language) and a certain character set, where the following characters are generally used:

abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1234567890_ 

So a space (" ") is therefore considered a different type of character, called a special character. It is therefore not very common for a language to allow the use of special characters in variable names!

Reserved words

In most languages there are a handful of words that may not be used as variable names, these are called reserved words. These are specified in the chapter corresponding to the specific language.

Constants

A constant is data type whose value cannot be modified. These are generally defined at the beginning of the program. The value of the constant may be of any type permitted by the programming language.

Comments

It is useful when writing a program to be able to add lines of text that the compiler does not treat as code. These lines of text are usually preceded (or enclosed) by special commands which tell the compiler to ignore them.

Comments are used to clarify how the program is written by explaining parts of the code. Comments are useful if another person is trying to understand how the program works by reading the source file, or even, if the person who wrote the program is reading the source file again some years after having originally written the code.

Last update on Thursday October 16, 2008 02:43:20 PM.This document entitled « Program structure » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the licence, as this note appears clearly.

Best answers for « Program structure » in :
Programming languages Show Programming language A "programming language" is a language designed to describe a set of consecutive actions to be executed by a computer. A programming language is therefore a practical way for us (humans) to give instructions to a...
Change the default installation folder C: \ Program Files ShowChange the default installation folder C: \ Program Files The installation of most software programs are set by default in the C: \ Program Files. Below is a means of how to change into another partition. Under Windows Vista, select...
The Add/Remove Programs icon is missing in Control Panel ShowThe Add/Remove Programs icon is missing in Control Panel When trying to add a program on your computer system, you suddenly noticed that the specific icon is missing. This can be due to Appwiz.cpl missing or damaged. This applet is...
Display Add/Remove Programs ShowDisplay Add/Remove Programs Solution When trying to uninstall a program in the add/remove programs, below error message appears on your screen: An unexpected error occurred Object does not support this property or method...
Structure of an email (Headers and bodies) ShowStructure of an email An email has three basic parts: The header, a set of lines containing information about the message's transportation, such as the sender's address, the recipient's address, or timestamps showing when the message was sent by...
Characteristics of programming languages ShowThere are many programming languages, each corresponding to specific needs (formula calculus, character string processing, real-time, etc.) with each having specific characteristics and functionalities. Therefore, the choice of programming language...
Structure tags ShowTags can be divided into two groups: Those which change the structure of the page, and those which change the text style. Structure tags include header tags, paragraph tags, list tags, and more. Attributes The following attributes are placed within...