Type Declarations :
the type declaration statement is used to specify the type and attributes of derived type objects such as arrays, pointer and functions.Purpose of type declarations :
- Type declarations assist the compiler in identifying the object to which the name refers to.
- In case, if no data types exist, there would be no type checking, which produces adverse effects on debugging and error checking. It also affects the program's reliability.
- Absence of data types also affects the language's readability as the objects with distinctive characteristics are difficult to isolate.
Components of type declarations :
A type declarative statement involves the following components.
- type - name : it refers to the name of already defined derived datatype.
- attribute - list : it consists of one or more attributes separated by a comma.
Example : int a,b,c;
A type declaration statement must end with a semicolon(;), values can also be assigned to attributes as follows.int a = 10, b = 5, c = 3;
The above type-declarative statement assigns the values 10, 5 and 3 to the int type variables a, b and c respectively.