The difference between “:” and “;” in Pascal
Hello Luisantos.
Colons (:) in Pascal are used in declaration of variables. Examples are:
program codesnippet;
var
x_int, y_int: integer;
z_real: real;
Notice how the colon separates the variable "x_int" and "y_int" from the data type "integer". It also separates the variable "z_real" from the data type keyword "real". Without the colon, the compiler will return a syntax error.
Notice in the same example that there are semi-colons (;) right after each line of code. The semi-colon indicates the end of a program statement in Pascal.
Obligatory? Yes, it is. The colon and semi-colon are part of the syntax of a Pascal program. Without it, it will be impossible to compile the source code into an object. Not being able to compile will mean it will not be possible to build the object file into an executable.
The difference between “:” and “;” in Pascal
In Pascal, the colon “:” symbol has many uses. It can be used in the declaration of a variable “var” or constant “const” to specify its identifier type. It can also be used in specifying a “case” statement entry. You can use it to separate the function type from function declaration. Similar to batch file programming, the colon symbol can be used to declare a label.
The semicolon “;” symbol shows the end of a statement. This symbol is mandatory and should appear after each statement. But there are also cases where the semicolon symbol is optional and sometimes forbidden. The locations where you can place this symbol optionally are either before the period at the end of a “UNIT” or “PROGRAM”, or before the “END” statement. On the other hand, you cannot use the semicolon symbol before the “BEGIN” statement or before an “ELSE” clause in a nested “IF” statement.
The difference between “:” and “;” in Pascal
Both of your answers are perfect and I wish to thank you also. Actually, I need to study about programming and I want to learn from it. That is why I am interested and curious to the TPW program because I would like to prepare my career as a workplace writer for working in every field of industry and public life, for that it was very essential for me to understand about the difference between using “:” and “;” in TPW program its obligatory use. Nicely in your comment you explained that colon “:” is used in specifying a “case” statement entry and semicolon”;” symbol is used the end of a statement. This information was really needed for me to be a good writer. Thanks guys for your sincere comment.