Exam 2829 IImid
Exam 2829 IImid
GE 209 Computer
2ed Semester 1428/1429 H
Time Allowed: 1:15 Hours
Midterm EXIMANATION
Question#
1
2
3
Total
: :
Mark
: :
QUESTION (1)
Draw CIRCLE around the right answer:
(i)
REAL:: A,B
A=37.555
B=5.2813
PRINT 10, A, B
10 FORMAT (1X,2E15.7)
STOP
END
The right print out is:
(a)b0.3755500E+02 b0.5281300E+01
(b)bb0.3755500E+02 bb0.5281300E+01
(c)b0.3755500E+02 bb0.5281300E+01
(d)bb0.3755500E+02 b0.5281300E+01
GIVEN
Logical Flag
Real:: A, B
Parameter (A=16.0, B=5.0)
Flag=A.GT.B
Logical Flag
Real:: A, B
Parameter (A=16.0, B=5.0)
Flag=Sqrt(A).LE.B
1.0
X log e X * log
cos y
(a) X=(log(abs(exp(-X))))*(log(abs(1.0/sqrt(cos(y)))))
(b) X=(log(abs(exp(-X))))*(log(abs(1.0/sqrt(cos(y))))
(c) X=(log(abs(exp(-X))))*(log(abs(1.0/skrt(cos(y)))))
(d) X=(log(abs(exp(-X))))*(log(abs(1.0/sqrt(cos(y))))
(ii)
LOGICAL EXPRESSION
A+B.LE.20.0.OR.Flag.EQV..False.
(b)False
B**2.LE.16.0.OR.Flag.NEQV..True.
N=0
DO M=5,7
N=N+(-1)**M
END DO
PRINT 10, N
10 FORMAT(1X,'N=',I2)
STOP
END
(a)True
(b)False
(iii)
OUTCOME
(a)True
SUM=0.0
N=1
10 SUM=SUM+N
N=N+1
IF(N.EQ.2) SUM=3
IF(N.LT.3) GOTO 10
PRINT *, N, SUM
STOP
END
The right print out is:
(a) 3 3.000000
(b) 3 4.000000
(c) 3 5.000000
(d) Syntax Error
: :
QUESTION (2)
Trace this program showing all results and printed outputs.
IMPLICIT NONE
LOGICAL:: DIS
INTEGER::M=7
REAL, PARAMETER:: B=5.
REAL ::Y,S,Z
DO Y=1,13,6
S=Y+M/2
DIS= B .GE. S
IF (DIS .EQV. .True.) THEN
Z=B-M
PRINT *, Y, Z
ELSE
IF ( Y+M .LE. 19. .OR. B .GE. 20.)
THEN
Z=MIN(Y,B)
PRINT *,Y,Z
ELSE
PRINT *, 'Invalid Y'
STOP
ENDIF
PRINT *, Z
ENDIF
ENDDO
PRINT*,Y,Z
END
Print out
DIS
QUESTION (3)
The cost per kilometer for a rented car is
0.5 SR/km for the first 100 Kilometer,
0.3 SR/km for the next 200 Kilometer, and
0.2 SR/km for all kilometers in excess of 300 km.
Write a FORTRAN program:
(a) Reads the kilometers traveled
(b) Determines the total cost using (if-else-if statement.
(c) Determines the average cost per km.