308-208 - Computers in Engineering - Previous Midterms

Midterm Winter 1995


Question 1. (11 minutes, 15 points)

Classify each of the following, according the rules of FORTRAN 77, by placing each one under the most 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:


Question 2. (11 minutes, 15 points)

What will the following program output?

      INTEGER  u,v,w
      REAL     x,y,z
      x = -2
      y = 1
      z = 1.3333
      w = 0.0
      u = 3.1
      Do 10 v=0, 4, 2
         u = u + 2.5
         IF ( mod(u,7) .LE. 2 )  THEN
            x = x + 3.1416
         ELSE
            y = y-1
         ENDIF
         IF ( y .LT. 0 )  z = -1.3333
         w = w + v
 10   CONTINUE
      PRINT *, u,v,w
      PRINT *, x,y,z
      END


Question 3: (11 minutes, 15 points)

What does this program print?

        I = 11.4
        J = I / 2
        K = I + J / 2
        X = 3.1
        Y = 2.7
        Z = X + (J-1)*Y
        CALL FOO (I, J, Z)
        CALL BAR (K, X, Y)
        X = MOD(9, 5)
        Y = Y * I
        Z = Y - X
        J = Z - 1.1
        PRINT *, I, J, K
        PRINT *, X, Y, Z
        STOP
        END
C
        SUBROUTINE FOO(M, N, X)
                M = (N + X) / 2.0
                RETURN
        END
C
        SUBROUTINE BAR(I, Y, Z)
                I = I + Y * Z
                RETURN
        END


Question 4: (12 minutes, 15 points)

What does this program print?

       CHARACTER*1 LETTER(6), OUTPUT(11)
       INTEGER INDEX(6)
C
       LETTER(1) = 'V'
       LETTER(2) = 'I'
       LETTER(3) = 'A'
       LETTER(4) = 'T'
       LETTER(5) = 'L'
       LETTER(6) = ' '
       INDEX(1) = 1
       INDEX(2) = 1
       INDEX(3) = 6
       INDEX(4) = 4
       INDEX(5) = 5
       INDEX(6) = 3
C
       DO 10 I = 1,11
         MORE = MOD(I,4)
         IF (MOD(I,2).EQ.0 .AND. MORE.EQ.0) THEN
           J = 3
         ELSEIF (MOD(I,2).EQ.0) THEN
           J = 2
         ELSE
           J = INDEX(I/2+1)
         ENDIF
        OUTPUT(I) = LETTER(J)
 10    CONTINUE
       PRINT *,OUTPUT
       STOP
       END


Question 5. (45 minutes, 40 points)

Write a simple FORTRAN 77 program to accept data in the following format:

Columns Description                                 Example

1-7             Student ID                                  9512345
11-35           Student Name                        St. Louis, Rejean
41-45           Total Course Assignments (100)    78
46-50           Mid Term also out of 100            67
51-55           Final exam out of 100               73

Your program should read a group of records with the above data, terminated by 9999999. For each input record, print the input data, under appropriate headings, and calculate and print the final course mark for each student, all on the same line. The course mark is calculated by counting the assignments for 30%, the midterm for 20%, and the final exam for 50%. The course mark should be printed to one decimal place for each student (e.g. 73.3 for the above example).

At the end of the class list, print the Student ID and Name of the TOP THREE students in the class.

Your program does NOT need to use 2-D arrays nor subprograms.

WRITE your program, with Control Lines, neatly:


End of Midterm