308-208 - Computers in Engineering - Previous Midterms
Midterm Fall 1993
1. (10 min., 10 points)
Classify each of the following by placing each one under
the appropriate column in the table. Assume no explicit
declarations.
PI PRODUCT AND TRUE DO 7 K 12.25
MANY .OR. .FLSE. *SUM
1ZERO IJK 3.0 123,000 0.0001
N $1.90 -445 .GT. AREA
Categories:
- Valid Fortran REAL Variable
- Valid Fortran INTEGER Variable
- Valid Fortran INTEGER Constant
- Valid Fortran REAL Constant
- Valid Fortran LOGICAL Operator
- Valid Fortran RELATIONAL Operator
- Not Valid in Fortran
2. (10 min., 12 points)
What will the following program print?
REAL d,e,g
a = 35/6
b = 2.5-4*3.0+a
c = mod(21,5)
d = 17/4*3
e = (10.0/4)**2
f = a+b
PRINT *,a,b,c,d,e,f
END
3. (10 min., 12 points)
What will the following program print?
REAL w,v,u
INTEGER z,y,x
y = 12./5
v = y
x = 16/2**3/3*2
z = (3.5)**2-11
w = 2**(7+1)/6+y-v
u = 1.1E1+1.1E-1
PRINT *,u
PRINT *,v,w
PRINT *,x,y
PRINT *,z
END
4. (10 minutes, 15 points)
What will the following program print?
INTEGER I,J
J=3
DO 10 I=1,17,3
IF ( (I .EQ. 1) .OR. (I .EQ. 16) ) THEN
IF ( I .EQ. 1) THEN
PRINT *, 'NEVER'
ELSE
PRINT *, 'TROUBLES'
ENDIF
ELSE
IF (I/J .LT. J) THEN
PRINT *, 'TROUBLE'
ELSE
PRINT *,'TILL'
J = J + 2
ENDIF
ENDIF
10 CONTINUE
PRINT *, 'YOU'
STOP
END
5. (10 minutes, 15 points)
What will the following program print?
REAL K, N
B = 3
N = 2.8
A = 10
K = 3.2
U = 3.2
Q = 7.8
Total = B + N + A + K + U + Q
CALL AVRG(A,Q,U)
CALL AVRG(B,K,N)
Q = A + B
A = Q*6
CALL ATOTAL(Total, A)
PRINT *, A,B,N,K,U,Q
PRINT *, Total
END
SUBROUTINE AVRG(Q,A,B)
Q = (Q+A+B)/3
RETURN
END
SUBROUTINE ATOTAL(A,B)
A = (A+B)/9
RETURN
END
6. (40 minutes, 36 points)
The business results of a company for one year are data in the following format.
- Columns 1-3 Month (e.g. JAN FEB ...)
- Columns 4-10 Units sold (e.g. 417 524)
- Columns 11-16 Sales ($'000) (e.g. $73,600 is entered as 73.6)
Write a FORTRAN 77 program to ..
- Find the total & average of data in Units & Sales
- Find the best & worst monthly sales values and the months in which they occur (e.g. MAY).
- Draw a Bar-Chart like the following mock printout.
The Bar indicates the sales (rounded to the nearest integer) in a month.
MTH SALES ($'000)
JAN ********
FEB *
MAR ************
APR *********************
MAY **********************
JUN ************************
JUL ***********************
AUG *************
SEP *******************
OCT ***********
NOV ********************
DEC *******************