Arithmetic
Statements
Expressions
Operation
Symbols'
18
Example:
Of
variables
that
are
subscripted:
A(})
K(3)
B(I,
J)
I ( 4,2)
BETA
(}-2
,K+4)
In
the
last
item
in
the
example above,
the
object program computes
the
value of
the
two-dimensional subscript
by
subtracting
2 from the value of J
and
adding
4 to
the
value of
K.
The
numerical calculations to
be
performed
in
the
object program
are
defined
by
arithmetic statements.
FORTRAN
arithmetic statements closely resemble conven-
tional arithmetic formulas.
They
contain a variable to
be
computed, followed
by
an
= sign, followed
by
an
arithmetic expression.
For
example,
the
arithmetic
statement
Y = A -
SIN(B)
means "replace
the
value of
the
variable on
the
left side of
the
equal
sign
with
the
value of
the
expression on the right side of
the
equal
sign."
In
a
FORTRAN
program,
the
equal
sign means "is to
be
replaced by"
rather
than
"is equivalent to."
The
meaning of
the
equal
sign is
important
in
FORTRAN.
Earlier in the manual
we
learned
that
each
variable in the obJect
program
is assigned a specific location
in storage
that
contains
the
data
you have named.
As
an example, assume a fixed
pOint variable
named
NUMBR
has the value of
6.
The
statement
NUMBR = NUMBR + 2
would cause
the
object program to take
the
value of
NUMBR,
which
is
6,
increase
it
hy
2,
and
then
set
the
result 8
as
the
new value of
NUMBR.
Format: "a = b"
a
is
a variable
and
may
be
subscripted
b is an arithmetic expression (explained
later)
Example:
A=B+C
D(I)
=
E(I)
+
2.-F
An expression
in
FORTRAN
consists of a series of constants, variables,
and
functions
(explained
later)
separated
by
parentheses, commas,
and/or
operation symbols,
so
as
to form a mathematical expression. Expressions
appear
on the right-hand
side of arithmetic statements.
Five basic operations
can
be
used in
FORTRAN:
addition, subtraction, multiplication,
division,
and
involution (raising to a
power).
These
operations are
represented
in
FORTRAN
by
the
following symbols:
+
*
/
**
addition
subtraction
multiplication
division
involution