Global variables are defined above main() in the following way:-
It is also possible to pre-initialise global variables using the = operator for assignment.
NOTE: The = operator is the same as := is Pascal.
This is the same as:-
...but is more efficient.
C also allows multiple assignment statements using =, for example:
...which is the same as, but more efficient than:
This kind of assignment is only possible if all the variable types in the statement are the same.
You can define your own types use typedef. This will have greater relevance later in the course when we learn how to create more complex data structures.
As an example of a simple use let us consider how we may define two new types real and letter. These new types can then be used in the same way as the pre-defined C types: