0% found this document useful (0 votes)
26 views

Exam 2829 IImid

This document appears to be a midterm exam for a Fortran programming course. It contains 3 questions testing various Fortran programming concepts. Question 1 has multiple choice items related to Fortran formatting, logical expressions, and loop constructs. Question 2 asks the student to trace a provided Fortran program and show the results and outputs. Question 3 asks the student to write a Fortran program that reads kilometers traveled, calculates the total cost based on different per km rates, and calculates the average cost per km.

Uploaded by

ahmed_kazim
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Exam 2829 IImid

This document appears to be a midterm exam for a Fortran programming course. It contains 3 questions testing various Fortran programming concepts. Question 1 has multiple choice items related to Fortran formatting, logical expressions, and loop constructs. Question 2 asks the student to trace a provided Fortran program and show the results and outputs. Question 3 asks the student to write a Fortran program that reads kilometers traveled, calculates the total cost based on different per km rates, and calculates the average cost per km.

Uploaded by

ahmed_kazim
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

:

King Saud University


Programming
College Of Engineering
Department Of Chemical Engineering

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

The correct Fortran expression is:

(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)

The right print out is:


(a) N=1
(b) N=-1
(c) N=0
(d) Syntax Error

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.

You might also like