CSE 1540.03
Week 2.2
January 11, 2012
Assignment Statement
variable
=
expression
Examples:
i = 1
the two most common
i = i + 1
assignment statements
c = 5*(f32)/9
x = 2.5
y = sin(x) + 3.14159
z = x / 10
n = m / 10
gives quotient from integer long division
Worries:
 unassigned variables
 type conversion (on assignment)
x = i
(real
←
integer)
O.K.
i = x
(integer
←
real)
loses fraction part
Arithmetic Expressions in Fortran
 Convert twodimensional mathematical notation to
onedimensional computer notation
Example:
a
ac
b
b
2
4
2

+

becomes:
(b + sqrt(b*b – 4*a*c))/(2*a)
Builtin Functions
(see Appendix 3 of textbook)
Elementary Math
sqrt(x)
square root (
)
exp(x)
exponential (
x
e
)
abs(x)
absolute value
alog(x)
natural logarithm (base
e
, ln)
alog10(x)
base 10 log
Trigonometric Functions
sin(x)
sine of angle x in radians
cos(x)
cosine of angle x in radians
atan(x)
arctangent of angle x in radians
asin(x)
arcsine of angle x in radians
CSE 1540
Week 2.2 – January 11, 2012
page 1 of
2
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document…
sinh(x)
hyperbolic sine of angle x in radians
Type Conversion Functions
nint(x)
rounds real x to integer
This is the end of the preview.
Sign up
to
access the rest of the document.
 Winter '12
 HOFBAUER
 Trigonometry, Logarithm, relational operator, double precision, 1540 Week

Click to edit the document details