In Fortran there are 5 intrinsic (i.e. built-in) data types:
integer
(whole numbers)
real (numbers with the decimal point or a
fractional part)
complex (complex numbers)
character
logical
The first three are the numeric types. The last two are non-numeric types.
Variables should be declared (that is, have their type defined and memory set aside for them) before any executable statements. This is achieved by a type declaration statement of the form, e.g.,
CHAR *1 A ! This is one character stored in one byte
INTEGER NUMBER_OF_PEOPLE ! This may be either two or four bytes of memory
REAL RESULT ! Usually four bytes
COMPLEX Z
LOGICAL ANSWER
Read section 4.1 to 4.4 in the FORTRAN95 Manual and answer following questions.
Exercises
1) Give 5 examples of the alphanumeric characters.
2) Give 5 examples of the special symbols.
3) How many types of tokens, and what are they?
4) What are the rules for choosing a valid variable name?
5) Identify the following constants as REAL, INTEGER, CHAR or COMPLEX
0 ___________ area ______ 13.76 _______ 1024 ______ 8M _________
20 + 10 i _____ -100 ______ 1.5 E-1 ______ +110 ______ 0.0 _________
6) The older versions of FORTRAN (such as FORTRAN77) implicitly assumed a type for a variable depending on the first letter of its name. How many letters are assigned for real, integer, character, complex and logical type? And what are they?
7) Which statement overwrites the implicit of FORTRAN variables?