Sie sind auf Seite 1von 5

90 Minutes

CENG 200 Final Exam


06/06/2013 09:30
There are 40 questions (each 2.5 points) for a total of 100 points.
Exam Type: A
All questions are multiple choice, no points will be lost for wrong answers.
Name:
Student ID:
Section:
Signature:
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
1)Assume that you want to keep a record of average income for
months for the year 2007 through 2013 inclusive. Which of the
following declarations best captures this data?

7) What is the output of the following program?


integer a(3), b(3), x, y, z
data a, x, y, z /1,2,3,4,5,6/
call sub (a,b)
a: do i=1,2
print*, a(i),b(i)
end do a
z= ifun (x,y); print*,x,y,z
end

a) REAL INCOME(2007:2013,12)
b) REAL A(6,12)
c) REAL INCOME(12:2007,12:2013)
d) REAL INCOME(7,12,2013:2007)
e) REAL INCOME(12,6)

subroutine sub (x,y)


integer x(3),y(3)
b: do i=1,2
if(mod(i,2).EQ.0) then
y(i)=x(i); x(i)=x(3-i)
else
y(i)=x(3-i)
endif
end do b
return
end

2) When CYCLE is executed within a DO/WHILE loop


a) All statements within the body of loop cycle together.
b) Depending on how to use it, all of the above might be true.
c) All statements below are skipped and control returns to the top
of the loop for next repetition.
d) it causes an infinite loop.
e) it stops the execution of the loop and control jumps to the first
executable statement after ENDDO or CONTINUE statement.

integer function ifun (a,b)


integer a,b
b=a+1; a=b/2; ifun=a+b
return
end

3) The operator /= is equivalent to (BONUS QUESTION)


a) Short form of c = a / b in an arithmetic assignment.
b) Short form of a / b = c in an arithmetic expression.
c) .NEQV. in a logical expression.
d) .NE. in a relational expression.
e) .NOT. in a logical expression.

a) 1 2
2 1
2 4 6

b) 1 2
1 2
2 5 7

c) 1 2
3 4
2 4 5

d)1 1
2 2
6 42

e) 1 2
1 2
2 4 5

8) Following declaration produces


4)What is the output of the following program?

integer ax,by
data ax, by, i /1, 2, 3/
ax = ax + by
i = i + ax
if ( ax > by ) goto (1, 2, 1, 2, 1, 2),i
stop
print*, ax, by, i
goto 1
end

DIMENSION ARRAY(2)
DATA ARRAY /12345,67890/

a) a compilation error
b) a two dimensional real array of 2 elements
c) a two dimensional array of 12345 x 67890 elements
d) a three dimensional real array
e) a one dimensional real array of 2 elements
9) What is the output of the following program?

a)No output b) 3 2 6

c) 1 1 2
113

d) 2 2 1
331

e) 2 2 2
333

x = ifn (1) + ifn (2) * ifn (3)


print*, x
end

5) What is true if the content of the array ABC was YES ?

integer function ifn (n)


print*, n-1, n, n+1
ifn = 2*n + 1
return
end

CHARACTER ABC (4)


a) Its content is same as the logical constant .TRUE.
b) Its content is same as the logical constant .YES.
c) Its content is the same as the array ( / , Y , E , S / )
d) Its content is the same as the array ( / T , R , U , E / )
e) Its content is the same as the array ( / Y , E , S , / )

Which of the following is an invalid declaration of an


array in main program?
6)

a) character address_information(100)
b) integer n(2:2,3:4)
c) integer parameter k=5; character a(k)
d) logical (true,false)
e) Real a(1,1,1)

a) 0 1 2
b) 1 2 3
c) 3 4 5
d) 2 3 4
e) 1 2 3
123
234
234
345
234
234
345
123
123
012
38.0
38.0
38.0
3.0
38
10) How many lines of output will the statements print?
5

a) Error

format ( 2 ( i5 / i4/ i3 ) )
m = 5
do k = 1, 5, 2
write (*,5) m , k, k+1
enddo
end

b) 3

c) 9

d) 10

e) 12

AAAAAAAAAAAAAAAAAAAAAAAAAAAA
11) What is the output of the following code?
integer x,y,z
x = 2.2; y = 3.3; z = 4.6
if ( x .EQ. y ) then
if ( y .EQ. 3 ) then
z = z + 1
else
z = z + 2
end if
else
if ( y /= 3) z = z + 3
end if
print*, z
end

a)

b) No output

c) 4

integer a(8)
data (a(i),i = 1, 8)/5, 3, 2, 1, 7, 2, 4, 1/
call sub1 ( a , 5 )
print*, a
end

d) 6

e) 5

12) Following declaration produces


REAL ARRAY (1,5,5,5)

a) a compilation error
c) an array of 16 real numbers
d) an array of 125 real numbers
e) a one dimensional array containing 1.0, 5.0, 5.0, 5.0 initially

13) What will be printed by the program below?


integer function ifun (k)
ifun = k+1
print*, k, ifun
return
end

b) 3 4
4 7

c) 7
7 7

subroutine sub1 (iarr , k)


dimension iarr ( k )
do i = 1 , k
m = i
do j = m , k
if ( iarr ( i ) < iarr ( j ) ) then
it = iarr ( i )
iarr ( i ) = iarr ( j )
iarr ( j ) = it
endif
end do
end do
return
end

a) 7 5 4 3 2 2 1 1
b) 7 5 3 2 1 2 4 1
c) 1 2 3 5 7 2 4 1
d) 1 4 2 7 1 2 3 5
e) 7 5 4 3 2 2 1 1
17) What

k = 7
m = 3
i = ifun (m)
print*, i , k
end

a) 3 7
3

AAAAAAAAAAAAAAAAAAAAAAAAAAAA
16) What is the output of the program below?

d) 7 7
7

e) 3
3 3

is wrong with the following segment?

integer function f1(x,y,z,m)


real function f2(y,x,z,m)
if(x+y<z-m)then
f1=x+y+z
return
else
f2=x-y-z
return
endif
end

a) There are more than one return statement.


14) Which CALL statement(s) is/are invalid?

(1)
(2)
(3)
(4)
(5)
a) (5)

b) order of the parameter lists must be same for f1 and f2.


c) return types of f1 and f2 are not same.

X = INPUT(array (i), i = 1,10)

d) stop statement is required.


e) function f2 defined inside f1.

X = SQTR(25.0)
X = SUM(T,Y,SIZE,15)
X = SQRT(25.0)

18) What will be printed after the execution?

X = CUBEROOT(A)

b) (3) and (4) c) (1) and (2)

d) (2)

e) (1)

15) What gets printed out by the following program?

a) 5
7
6

character course (4)


data (course(i),i=1,4)/4HCENG,200,
"4TRAN","PROGRAMLAMA"/
print*, (course (i), i = 1, 4)
end

integer t
t = 5.0
print*, t
i = kfun ( t )
print*, i
end

a) C24P
b) C3FP
c) CENG200FortranProgramming
d) CENG3H200FortranProgramming
e) CENG 200 Fortran Programming

integer function kfun ( it )


it = it + 2
print*, it
kfun = it-1
return
end

19) What would be the output of the following program?

b) 5.0

c) 5.0

7
6

5
6

d) 6

e) 5.0

5
6

7.0
6.0

integer A(4,4)
do 55 i=1,4
do 55 j=1,4
55 A(i,j) = i*j
do 66 i=1,4
66 write(*,77) (A(i,j),j=1,i,1)
77 format(4(1x,i3))
end

AAAAAAAAAAAAAAAAAAAAAAAAAAAA

AAAAAAAAAAAAAAAAAAAAAAAAAAAA

a) 1 2 3 4 b) 1 2 3 4 c) 1
2 4 6 8
2 4 6
2 4
3 6 9 12
3 6
3 6 9
4 8 12 16
4
4 8 12 16

24) Which declarations cause error?

d) 1
e) 1 2 3
2 4
2 4
3 6 9
3

real x,y
do x = 5.2 , 3.2 , -1.2
do y = 1.2 , 10.0 , 1.2
print*, x , y
end do
end do
end

b) 144

c) 169

d) 16

e) 256

d) 1
1
0

e) 1
2
0

a) 7 2 4
725
726

b) 7 2 4

c) 2 1 2
313
212
313

d)2 1 2
313
222
323

e) 2 1 2
313
724
835

integer ARR(4,4)
data ARR / 1,5,9,13,2,6,10,14,3,7,11,15,4,8,12,16/
do 5 i = 1, 3
do j = 1, 3
it = ARR(i,j)
ARR(i,j) = ARR(j,i)
ARR(j,i) = it
end do
continue
do i = 1 , 3
print*, (ARR(i,j),j = 1,4)
end do
end

a) 1 2 3
5 6 7
9 10 11
13 14 15

c) 1, 2 and 3

d) 5

e) 4 and 5

data I , J , X /1.2, 2.3 ,3/


print*, I,J,X
call sub (I,J)
print*, I,J
end

e) 1 2.3 3.0
3 1.0
4.0
3 1.0

26) What are the values of the elements in array def, after the
execution?

23) What will be the content of the integer array ARR after the
execution of the code below?

b) 1

a) 1.2 2.3 3.0 b) 1 2.3 3 c) 1 2 3.0 d) 1.2 2 2


3 1
3 1
3 1
3 1
4
4
4
4
3 1.0
3 1
3 1
3 1.0

integer ax, by, i


data ax, by, i / 3*2 /
do k = 1, 2
ax = ax + i
i = i + 1
if ( ax > by ) goto (1, 2, 1, 2), i
exit
print*, ax, by, i
goto 1
end do
stop
end

real array1 (10)!!!


real array2 (10)!!!

subroutine sub (M,N)


integer XYZ, SAYI
M = M + 2
N = N - 1
SAYI = XYZ(M,N)
print*, SAYI
return
end

22) What is the output of the following program?

real array1 (10), array2 (2*10+1)

integer function XYZ (J,I)


print*, J,I
XYZ = J + I
return
end

end

c) 2
2
2

INTEGER BOY; read*, BOY


real array1 (BOY), array2 (BOY)

25) What will be printed by the following program?

function k()
do 5 i=1,1; print*,i
end do
k=i; return

b) 2
2
0

3.

a) 2 and 3

implicit none
integer i,j,k
j=1; do 5 i=2,1,-1
5 j=j+k()
print*,i; end

a) 1
1
-1

INTEGER BOY; BOY = 10


real array1 (BOY), array2 (BOY)

4.
5.

21) What is the output of the following code?

integer, parameter :: BOY = 10


real array1 (BOY), array2(2*BOY)

2.

20) How many lines of output will be displayed by the following


code?

a) 132

1.

4 b) 1 2 3 4 c) 1 2 3 d) 1 1 1 e) 1 2 3 4
8
5 6 7 8
4 5 6
2 2 2
1 2 3 4
12
9 10 11 12
7 8 9
3 3 3
1 2 3 4
16
10 11 12
4 4 4

integer abc (3), def (3)


data (abc (k), k = 3, 1, -1 ) /5, 3, 1/
data (def (k), k = 3, 1, -1 ) /3 * 2/
k = 1
do while ( k .LE. 3 )
m = 2
def (m-1) = k * 2
k = k + 1
m = m + 1
end do
print*, def
end

a) 6 2 2

b) 6 4 2

c) 3 3 3

d) 1 1 1

27) What is the output of the code below?


real array (0:0,0:0,2,0:0)
data array /2*0020/
print*,array
end

a) 2242.00
b) 0.0 0.0 2.0 0.0
c) 20.0
20.0
d) 0.0 0.0 4.0 0.0
e) 2242 2242

e) 9 9 9

AAAAAAAAAAAAAAAAAAAAAAAAAAAA
28) What is the content of array ARR after the execution?

AAAAAAAAAAAAAAAAAAAAAAAAAAAA
32) What gets printed out by the following program?
character (len=7) :: a1,a2,a3,a4,a5
data i,j /20,15/
a1 = 3HAli
if (i/=j .and. j==0) then
a1 = 4HVeli; i=i/2
endif
a2 = 6HGelmis
if (i<j .or. j>=20) then
a2 = 6HGitmis

integer ARR( 9 )
data (ARR (i),i=9,1,-1) /9,8,7,6,5,4,3,2,1/
do i = 1,5
it = ARR (i)
ARR (i) = ARR (6-i)
ARR (6-i) = it
end do
print*, (ARR(i),i=1,9)
end

a) Ali Gelmis Gelmis Veli Nerede?


b) Veli Gelmis Gelmis Ali Nerede?
c) Ali Gelmis Gitmis Veli Kim?
d) Ali Gitmis Gitmis Veli Kim?
e) Ali Gelmis Gelmis Veli Kim?

a) 9, 8, 7, 6, 5, 4, 3, 2, 1
b) 5, 6, 7, 8, 9, 4, 3, 2, 1
c) 9, 8, 7, 6, 5, 1, 2, 3, 4
d) 1, 2, 3, 4, 5, 6, 7, 8, 9
e) 5, 6, 7, 8, 9, 1, 2, 3, 4
29) What will be printed after the execution?
character *3 course (4)
data(course(i),i=1,4)/4HCENG,"200","4TRAN","PROGRAMLAMA"
/
print*, (course (i), i = 1, 4)
end

a) CENG3H20FortProg
b) CEN2004TRPRO
c) CENG
200
Fort
d) CENG
3H20 Fort
e) C24P

Progr
Prog

30) What is the output of the following program?


CHARACTER (len = 2) , DIMENSION ( 3 ) :: XYZ
CHARACTER (len = 2) , DIMENSION ( 4 ) :: ABC
data XYZ / "AAAAA" , "BBBBBB" , "CCCCCCC" /
data ABC /"AAA", "BBBB", "CCCCC", "DDDDDD"/
print*, XYZ(1), XYZ(2), XYZ(3)
print*, ABC(4), ABC(3), ABC(2), ABC(1)
end

a) ABBCCC
DDDDCCCBBA
b) AAABBBCCC
DDDDCCCCBBBBAAAA
c) AABBCC
DDCCBBAA
d) ABC
DCBA
e) AABBCC
DD
31) What is the output of the code below?
real BX
integer M
Bx = 0.5
bX = 1.5
M = Bx - bX
m = bX - Bx
BX = (m + M) * ( bX - 5 / 3 )
print*, M, 5HAAAAA , BX
end

a) -1.0 AAAAA
b) 0 AAAAA
c) -1 AAAAA
d) 0 AAAAA
e) 0 5HAAAAA

0.0
0.0
0.0
0
0.0

33) What can be said about the DO loop

DO N i=e1,e2,e3
Statements
CONTINUE

a) number of repetition of the loop body can be calculated by


a special formula.
b) e1 can not be of real type
c) i must be an integer variable
d) if e2 is omitted it is assumed as 1
e) e3 can not be omitted.
34) What is the output of the following program?
character*2 array (7)
data array /'aaa','bb','cccc','ddd','eee','fff','ggggg'/
do i=1,3
array (i) = array (7-i-1)
end do
print*,(array (i), i=7,1,-1)
end

a) aaabbccccdddeeefffggggg
b) gggggfffeeedddcccceee
c) ggffeeddccee
d) abcdefg
e) gfedce
35) To give a name such as Area of a Triangle to a program,
which of the below has the valid syntax?
a) The first statement must be: PROGRAM Area of a Triangle
The last statement must be: END PROGRAM Area of a Triangle
b) The first statement must be: PROGRAM NAME : Area of a
Triangle
The last statement must be: END PROGRAM
c) The first statement must be: PROGRAM ID: Area_of_a_Triangle
The last statement must be: END ID
d) The first statement must be: PROGRAM Area_of_a_Triangle
The last statement must be: END PROGRAM Area_of_a_Triangle
e) The first statement must be : !!! Area of a Triangle

36) Given the declaration in a main program below:


integer, parameter :: row = 25
integer, parameter :: col = 36
logical::arr1(row,col), arr2(1+row,2+col), arr3(row*3-1)

c) 2
d) 2
e) 2

40) What is the output of the following program?

a) Validity depends on the Operating System used in the


computer.
b) Invalid declaration: logical values are .TRUE. and/or
.FALSE.
c) Valid declaration.
d) Invalid declaration: array size(s) must be numerical
(integer) constant.
e) Invalid declaration: array size(s) must be numerical
(integer) constant an can not be an expression.

real array (0:0,0:0,0:0,0:0)


data array /1111/
print*,array
end

38) What is the output of the code below?


(Letter B is used for blank/space character)
X=(-358.761)
T=999.999
M=(-358.06)
N=358
WRITE (*,5) M,N,T,X
FORMAT (2I3,2X,F7.2,/,1X,F6.1)
End

a) ***
358
BB1000.00B-358.8
b) ***358BB1000.00
B-358.8
c) 358358BBB999.99
B-358.8
d) ***358
BB1000.00B-358
e) -358.06358BB999.999
B-358.06
39) What is the output of the following code?
integer a(11)
data n/11/
call sub(500,a,11)
print*,((a(i)), i = 1, 10)
end
subroutine sub(n,x,isize)
integer index, n, x(isize)
index2 = 1
do index = 2, n/2
if (mod(n,index).EQ. 0)then
x(index2)= index
index2 = index2 + 1
end if
end do
return
end
a) 1 2 3 5 8 13 21 34 55
b) 0 4 5 10 20 25 50 100 125

1
3

b)
c)
d)
e)

a) 1111.0 1111.0 1111.0 1111.0


b) 1.0 1.0 1.0 1.0
c) 0.0 0.0 0.0 0.0
d) 1111.00
e) 1.0

a)

37) What is the output of the code below?

89
250

4 5 10 30 60 100 125 250 500


4 6 10 20 30 60 100 150 250
4 5 10 20 25 50 100 125 250

integer x
data x, i /1, 2/
x = x * (-2)**2
if (x) 3, 2, 1
print*, x
goto (2, 3, 1), x
print*, x
stop
end

4
4
1
Infinitely many (4)s will be printed.
Infinitely many (1)s will be printed.
No output will be produced.

Das könnte Ihnen auch gefallen