Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
28.04.2015 17:40
There are 40 questions (each 2.5 points) for a total of 100 points.
Exam Type:
All questions are multiple choice, no points will be lost for wrong answers.
Do not forget to mark your student ID and exam type correctly to the answer sheet. Otherwise, your answers will not be graded.
Assume that all necessary libraries were added properly (by using "include" statements).
Default return type of the main function is int. Assume that the statement return 0; is added to programs if necessary.
Name:
Student ID:
Section:
b) abc
c) cb.a
d) bc.a
a) (a**c)**b
b) (a**b)**c
c) (c**b)**a
d) a**(c**b)
e) a**(b**c)
3) Given the contents of the variables:
a) 3.000 3.0
d) 3.000 ***
c) .f. d) .TRUE.
e) .YES.
write(*,10)57.388,55555
format(f5.2,/,i3)
end
b)57.39/
***
***
c)57.38
***
d) 57.388
555
e) 57.39
555
real x; integer y
y=9.9; y=x
print*,y; end
b) 9
b) 14.0
c)10.0
e) 2.8
d)5.0
c) 9.0 d) 10
e) Unknown/Undefined
i=1; j=5
if(j>6.and.i+1>0) then
i=i+1; print*,"A"; else
print*,"B"; end if
if(j>0.or.i+1>0) then
i=i+1; print*,"C"; else
print*,"D"; end if
print*,i
end
b) BC2
a=7/5
if(a-1/=0)then; print*,10*a
else if(a==(a+1)/4)then; print*,2*a
else; print*,5*a; end if; end
a) 2.0
a) B
C
2
b) .3E+01 .30E+01 3
d) ****** ******* 3
a) 10.0
c) ***** 3
isum=17; icount=5
x=isum/icount;
write(*,1)x,x,isum/icount
format(e6.3,1x,e7.2,1x,1i2)
end
a) .3E+1 .30+E1 3
c) ****** .30E+01 3
e) .3e+1 ******* 3
a) 57.39
b) 3.000 3
e) 3.000 3.4
10
isum=17; icount=5
x=isum/icount;
write(*,1)x,isum/icount
format(f5.3,1x,i2)
e) ba.c
a) *T* b) .FALSE.
Signature:
c) A
K=5/2
if(K)1,2,3
1
K=K+1; goto(1,2,3),K
2
K=K+2; goto(2,3),K
3
print*,K; end
a) 2.5
b) 2
c) 3
d) 4
e) 4.5
d) B
C
3
e) A
C
3
K=5/2
goto(1,2,3),K
1
K=K+1; if(K)1,2,3
2
K=K+2; if(K)1,2,3
3
print*,K; end
a) 4.5
b) 2
c) 2.5
d) 3
e) 4
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
18) Which of the following if statements is doing the action
that is verbally specified as:
if a is smaller than b then c is assigned the value of a,
otherwise c is assigned the value of b
4
1
2
3
a) 3.5
b) 3
c) 2
d) 2.5
a) if
b) if
c) if
d) if
e) if
e) 4
a) 57.0
101
d) 56.0
b) 57.0
101
100
e) 56
c) 57
102
101
a) 11.33 18.00
b) 12.00 18.00
c) 11
18
d) 11
18
e) 12.00 18.00
a) OK
OK
c)8
a) FALSE
d) 5
e)9
10
d) 45.26
a) 1
b) 2
c) 4
OK
FAIL
d) FAIL
e) Compile-time Error
FAIL
d) 6
b) .TRUE. c) 4HTRUE
d) 5HFALSE
e) TRUE
integer result
a=4.5255; b=10.0
result=a*b
print*,result
end
c) 45.0
b) FAIL c) OK
i=10; j=0
if(i.EQ.20.OR.j-1/=0)then
print*,4HTRUE
else
print*,5HFALSE
end if
end
b) 45
2
1.5
2
1
2
a) 45.255
1.00
2.00
2
2
2.00
real :: a=1.0
if(3<2.OR.3<4.AND.5>6)then
print*,'OK'; else; print*,'FAIL'; endif
if(.NOT.5>6.AND.(a/=2.0))then
print*,'OK'; else; print*,'FAIL'; endif
end
if(c.GT.(a,b))then
print*,"OK"
else
print*,"NO"
endif
b)5.0
2.00
2.00
2.12
2.12
2.00
a) Only I
b) Only II
c) Only III
d) I and III
e) II and III
a) 8.0
e) 46
i=-5000
i=i+1
if(i.NE.0)then
if(.NOT.mod(i,3).EQ.1)goto 10
print*,'TAKA TUKA'
i=i+1
if(i>10)STOP
goto 10
end if
end
a) 0 times
b) 7 times
c) 10 times
d) 5000 times
e) infinitely many times
e) 8
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
a) 4
b) 4.0
c) 0.0 d) 0 e) Run-time Error
29) What is the output of the following Fortran Program?
a) 1
2
3
d) 1
2
3
k=10; i=1
10 if(i>k)stop
if(mod(i,2).eq.0)then
k=k/3;else
if(mod(i,3).eq.0)then
k=k/2; else
k=k*2
endif
endif
print*,i,k; i=i+1; goto 10
end
20
b) 1
20
c) 1
6
2
6
2
3
3
3
3
4
1
6.6
3.3
3
integer x; x=2
if(x.eq.3)then; y=1
if(x.le.3)y=2; else; y=3
print*,y; endif
print*,y
end
a) 1.0
b) 3.0
1.0
20
6.66
3
c) 2.0
2.0
d) 3.0
2.0
e) 2.0
3.0
3.0
e) No output
11
51
21
41
61
a) aaa
a) 0 times
b) 10 times
c) 5 times
d) 4 times
e) Infinitely many times
x=3.0
if(x-4.0) 11,21,11
if(x-3) 41,51,41
print*,"a"; goto 61
print*,"aa"; goto 61
print*,"aaa"
stop
end
b) aa
c) a
d) a aaa
e) aa aaa
a) 4
b) 0.0
c) 4.0
k=0;
k=k+1
if(k<3)then
read*,i
if(mod(i,3).ne.0.and.mod(i,5).eq.0)then
print*,"A"; else
if(mod(i,3).ne.0.and.mod(i,2).eq.0)then
print*,"B"; else
print*,"C"; end if; end if; end if; end
a) A
d) Error
e) 0
c) 4.0
d) 4
e) Runtime Error
a) Run-time Error
b) 0.0
c) 4
e) C
a) A
b) B
c) C
d) C
e) C
d) 0
e) 4.0
d) C
k=0;
k=k+1
if(k<3)then
read*,i
if(mod(i,3).ne.0.and.mod(i,5).eq.0)then
print*,"A"; else
if(mod(i,3).ne.0.or.mod(i,2).eq.0)then
print*,"B"; else
print*,"C"; end if; end if; end if; end
integer a; real x
a=3.0
x=a/a/4
b) 0.0
c) C
a) 0
b) B
a) 6
b) 5
c) 6.0
d) 5.0
e) .FALSE.
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
34)What is the output of he following code?
kk=25; ii=15
10 if(ii.GT.kk)stop
if(mod(ii,2).EQ.0)then
kk=kk/3
else; if (mod(ii,3).eq.0)then
kk=kk/2
else; kk=kk*2
endif; endif
print*,ii,kk
ii=ii+2; goto 10
end
a) 15
12.5
d)17
b) 15
12
24.0
e)15.0
c)17
a) Only IV
d) I and III
a) A
c) C
c) I,II,IV
e) None of them
a=3.0
if(a-4)100,200,100
if(a-3)400,500,400
print*,'A'; goto 600
print*,'B'; goto 600
print*,'C'
stop; end
b) B
b) I and IV
24
12.0
implicit none
real
:: m=5
integer :: x=7.5
T=m*x
K=m+x
print*,m,x,T,K
end
100
500
200
400
600
integer :: a=1.0
real :: i=2
real :: c=3
character :: d='CEng200'
d) AB
e) AC
a) 5
7.5 37.5
12.5
b) 5.0 7
35.0
12
c) 5
7.5 35.0
12
d) 5
7.5 35
12.0
e) Compile-Time error
integer A , B
A=1; B=2
a=2.5; b=3.2
x=A+b
y=a+B
z=B*(a+b)
print*,x,y,z
end
a) 5.0
c) 4.0
e) 4
5.0
4.0
4
15.0
11.0
11
I)
read*,k
s=1; i=1
5 s=1+1/s
if(i.le.k-1)goto 5
...
III) read*,k,s,i
5 s=1+1/s
print*,s
a) Only I
d) Only III
read*,ix,iy
if(ix>0)then
if(iy>0)then
print*,1
else
print*,4; endif
else if(ix<0)then
if(iy>0) then
print*,2
else
print*,3
endif
else
print*,0
endif
end
a) 0
b) 1
c) 2
d) 3
e) 4
b) I and II
e) Only II
II) read*,k
s=1; i=1
5 s=1+1/s
if(i.gt.k)goto 5
...
IV)
s=1.0; read*,i
5 sk=1.0+1.0/sk-1
i=i+1
if(i<k) goto 5
...
c) Only IV