Arithmetic expressions
The types of numerical expression possible include the following. Similar
forms are possible for the other expression classes. In each case an
example is given for an expression used as a
parameter to a function and as
a right side value in a simple assignment.
- simple constant
- as in
- simple variable
- as in
- cos(Angle)
- Number = CurrentTotal;
- constant expression
- as in
- sqrt(4*8.6)
- TwoPi = 2 * 3.1415926;
- expression containing variables
- as in
- ceil(Val1*Val2 - Val3)
- Centigrade = (Fahrenheit-32)/9 * 5;
- value returned when a function is called
- as in
- abs(sin(3.4))
- Centigrade = tan(angle1);
Expressions containing only a single constant or only a number of constants and appropriate
operators (cases one and three above) represent a value which is always fixed.
Those containing one or more variables will have their value determined by the values currently
stored in these variables whenever that statement is executed.
Exercises on this section.
Next.
Back to Contents page.