Practice Problems with Operations
For the following questions, suppose we have these variables:
INTEGER :: A = 17, B = -3, C
REAL :: X = 4.2, Y = 1.9, Z
CHARACTER(5) P = 'OLIVE'
CHARACTER(6) Q = 'PEPPER'
- Find the value of each of these arithmetic expressions.
- A * 2 + B / 3
- A * (2 + B) / 3
- B ** 2 / (A - 8)
- B ** 2 / A - 8
- B * Y
- X + MOD(A, 5)
- 5 ** (B + 2.0)
- 5 ** B + 2.0
- These have to do with assignment statements.
- Suppose we have this statement: C = X + Y
What value is in C?
- Suppose we have this statement: Z = A / 4 + A / 4.0
What value is in Z?
- Suppose we have this statement: C = X / 5 + Y * 2
What value is in C?
- Suppose we have this statement: Z = 4.0 + B * Y
What value is in Z?
- Find the value of each of these logical expressions.
- (X .GT. 4)
- ((Y .LE. 2) .OR. (-6 * B .GE. A))
- ((X + Y < 7) .AND. (MOD(B, 3) .EQ. 0))
- ((A .LT. 4 * X) .EQV. (Y .GT. B * 2 / -3))
- ((B + Y .GE. -2) .NEQV. (A - X .LT. 13))
- Find the value of each of these character expressions.
- Q(3:4)
- P // 'OYL'
- Q(1:1) // P(1:1) // Q(2:6)
- P(2:5) // Q(3:6)