308-208 - Computers in Engineering - Previous Midterms
Midterm Fall 1992
1. (10 min., 12 points)
What will the following program write? (Remember that integers are
real numbers are printed differently)
INTEGER a,b,c WRITE YOUR ANSWERS HERE
REAL d,e,g
a = 25/3
b = 2.5-6*3.0
c = mod(13,4)
d = 15/4*3
e = (10.0/4)**2
f = a
PRINT *,a,b,c,d,e,f
END
2. (10 min., 12 points)
What will the following program print.
REAL w,v,u
INTEGER z,y,x
y = 12./5
v = y
x = 18/2**3/3*2
z = (3.5)**2-11
w = 2**(3+1)/6
u = 1.1E1+1.1E-1
PRINT *,u
PRINT *,v,w
PRINT *,x,y
PRINT *,z
END
3. (10 minutes, 10 points)
What will the following program print?
I=3
J=5
K=2.4
A=1.2
B=2.1
C=8
CALL FOOBAR(B,C,A)
CALL GRBNTZ(J,I,K)
CALL GRBNTZ(I,I,7)
E=C/4.0
F=8.0*K
CALL FOOBAR(D,E,F)
PRINT *,I,J,K,L
PRINT *,A,B,C,D,E,F
END
SUBROUTINE GRBNTZ(I,J,K)
I=(J+K)/2
RETURN
END
SUBROUTINE FOOBAR(A,B,C)
A = (B-C) /2.0
RETURN
END
4. (10 minutes, 14 points)
What will the following program print?
integer i, j(100), k(100), n
integer a,b
read *,n
read *, (j(l), l=1,n)
read *, (k(l), l=1,n)
do 10 i = 2, n
a=k(j(i))
b=k(j(i-1))
print *,i,a,b,(a+b)
10 continue
stop
end
/data
6
5 2 1 4 3 6 7
6 19 10 3 16 14 2
5. (10 minutes, 14 points)
What will the following program print?
INTEGER A,B
DO 22 A=13,23,4
DO 33 B=1,3
IF (MOD(A,B).GT.B/3) THEN
IF (A/6.GE.B) THEN
PRINT *,'HEGEL'
ELSE
PRINT *,'NIETZSCHE'
ENDIF
ELSE
PRINT *,'SPINOZA'
ENDIF
33 CONTINUE
22 CONTINUE
STOP
END
6. (40 minutes, 38 points)
The results of an English test are data in the following format:
- Columns 1 - 20 Name
- Columns 21 - 22 Score - a 2 digit integer from 0 to 99 inclusive
Write a FORTRAN 77 program to draw a bar graph like the following mock
printout. The bar indicates the percentage of the students who falls in
that category. The number after the bar is the actual number of
students in that category. Your program should also produce a
neat classlist of student names and marks - this can be
printed before or after the bar chart.
10 20 30 40 50 60 70 80 90 100%
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
0 - 50 . * * 15
.
51 - 60 . * * * 30
.
61 - 70 . * * * * * * * * * * * 105
.
71 - 80 . * * * * * * * * * 90
.
81 - 90 . * * * * * 45
.
91 -100 . * * 15
.
WRITE your program, with Control Lines, neatly here:
(Use the back of pages if needed)