Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
75 Minutes 30.04.2013 – 17:40 CENG 230 Midterm Exam There are 30 questions (each 3.4 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: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 7) What is printed by the following Fortran 1) Which operator below has highest program? precedence in a fortran expression? a=2 ; b=3 if(a-3)10,20,10 a).AND. b).OR c).EQV. d).NOT. e) .NEQV. 10 if(a-2)40,50,40 . 50 print*,'a' ; goto 60 20 print*,'b' ; goto 60 2) What is the result of the following 40 print*,a,b expression? 60 stop (2*7/3+mod(7,3)+ 2**1**3)/50 End a)0 b) 7 c) 13 d) 7.33333 e) 13.33333 3) What is the output of the following program? a=4 ; b=5 ; c=10 ; x=2 ; y=35 if (a>=b) then print*,a if (a<c) print*,c else print*,b if (a<x) then print*,x endif endif end a) 4.0 b) 5.0 c) 5 d) 2.0 e) 10.0 4) What is the output of the fragment below? real x x=2-8/3 print*,x end a)0 b) -2 c) -3.0 d)-2.66666 e) 0.0 5) mod (i,j) is equivalent to a) i/j*j b) i/j c) i-i/j*j d) i/j*i e) i-i/j*i 6) What is the FORTRAN equivalent of the following algebraic assignment statement? y = a1/2 a) b) c) d) e) y y y y y = = = = = a ** 1.0 / 2.0 a ** (1 / 2) a ** (1.0/2) (a ** 1.0) / 2.0 (a ** 1)**2 a) a b) 2 c) b d) 3 e) 2 3 8) What does the following fortran program do? (remember the recitation hours) ic=0 m=9999 read*,n 100 read*,nm ic=ic+1 if(nm<m)m=nm if(ic<n)goto 100 print*,'result is=',m stop end a) Sum of integers from 1 to 9999. b) Smallest of n integers,supposing that the numbers are all less than 9999. c) Average of 9999 integers. d) Minimum of n integers, supposing that the numbers are all greater than 9999. e) Maximum of n integers, supposing that the numbers are all less than 9999. 9) What will be the printed value of k if m is read as 2? k=1; n=1 read*,m 10 n=n+1 k=k-m if(n<=m)goto 10 print*,k end a) 0 b) -1 c) -2 d) -3 e) 1 10) What will be printed by the following program? logical karar karar=.NOT.5<=5.EQV.5<5 print*,karar end a) 0 b) 5 c) Error d) F e) T AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 11) What is the output of the following program? integer x,y,z x=5; y=50; z=500 if(.NOT.(x.NE.y))then x=50 else if(3<=4.OR.y.EQ.z)then y=500 else if(.NOT.y/=z/10)then z=5000 endif print*,x+y+z end AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 15) What is the output produced by the following program? i=5 goto(1,2,3)1-i 1 print*,1 2 print*,2 3 print*,3 End a) 1250 16)An algorithm is b) 5550 c) 1005 d) 5505 e) 600 12) Which of the expression results the value ‘Ankara’ ? a) b) c) d) e) HAnkara “6HAnkara” ‘An’ .AND. ‘kara’ Han//Hkara 2Han//4Hkara 13) What will be printed by the following fortran program? integer i,k k=20 ; i=3 10 if(i>k)stop if(mod(i,2).EQ.0) then k=k/4 else if(mod(i,3).EQ.0) then k=k/3 else k=k-1 endif endif print*,i,k ; i=i+2 ; goto 10 end a)5 5 3 6 b)3 8 5 5 c)3 6 5 5 d) 3 6 5 5 e) 5 5 1 7 14) What will be printed by the following program? real x; integer y x=5/3*(1./2) y=x print*,x , y end a) 0.5 0 d)0.5 0.0 b)0.0 0 e)0.5 0.5 c)0 0.0 a)No Output b) 1 2 3 c) 2 3 d) 3 e) -4 a) a procedure consisting of only fortran77 and/or 90 programming instructions for solving a problem. b) Analysis step by step of a given problem. c) Analysis byte by byte of input data stream (record). d)a procedure consisting of precisely defined steps for solving a problem. e) Design of output produced by the computer program. 17) Which of the below is an incorrect declaration? a) integer i ; real x b) integer i , real x c) character (len=10) letter_1 , letter_2 d) complex building ! xyz e) logical relations; logical speaking 18) What is the content of variable N after the execution of the following code? integer X real N X=5 N=X/2/X print*,N; end a) 0.0 b)0 c)0.5 d)12.5 e) Error 19) What is the content of variable N after the execution of the following code? integer X real N X=5 N=X/(2/X) print*,N; end a) 0.0 b) 0 c) Error d) 12.5 e) 0.5 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 20) What is the content of variable N after the execution of the following code? integer X real N X=5 N=X/(2.0/X) print*,N; end a) 0.0 b) 0 c) 0.5 d) Error e) a) b) c) d) e) 12.5 21) What will be the output of the program? integer a a=1.5 if(a.EQ.1)then print*,a+1 else print*,a-1 endif end a) 2.5 b) 0.5 c) 2 d) 0 e) 3 i=5 if(1-i)1,2,3 1 print*,1 2 print*,2 3 print*,3 End b) 1 2 3 c) 2 3 d) 3 m1=739 ; m2= -558 x1=3.14159 ; x2=314.159 write(*,10)x1,x2,m1,m2 10 format(2(f6.2,1x)/2i3) end b) 3.142 314.16 739 c) 3.14 314.16 739-55 d) 3.14 314.16 739-558 e) 3.14 314.16 739*** 25) If the input stream is B23-796789-157BBBBB then, what will be printed by the following code? (Where letter B represents a blank character) a) b) c) d) e) BB23***BB729 23BB****BB729 BB23****729 BB23***xx729 BB23-1572x729 26) If x1=367.25, x2=3.6725, x3=-0.36725 and x4=2.32 then what will be printed by the following code? (Where letter B represents a blank character) e) Write(*,20)x1,x4,x3,x2 20 format(f6.1,f5.3,f6.3,f2.1) -4 23) What is the output of the following code? a) 3.14 1x 314.15 739**** <1,2> 1+2i 1.0+2.0*sqrt(-1) <1.0 , 2.0> Error read(*,75) K1,K2,K3,K4 75 format(I3,4x,I3,2I4) Write(*,86)K1,K3,K4,K2 86 format(I4,I3,I4,2x,I3) 22) What will be printed by the following statements? a)No Output AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 24) What will be printed by the following program? complex a a=(1,2) print*,a end a) b) c) d) e) 0367.22.32B-0.3673. B367.33.32B**.367** B367.32.320-0.367** 0367.33.320-0.368*** B367.23.320-0.368**** 27) If x=-25.63E1 then what will be printed by the following segment? write (*,70)x 70 (e10.3) a) b) c) d) e) -25.63E+01 -256.300 -2.563E+02 -2563.E-01 –0.256E+03 A A A A A A A A A A A A A A A A A A A A A A A 28) What is the output produced by the following program? !integer pi 5 format("pi=",f6.4) pi=3.14159 write(*,5)pi end a) b) c) d) e) pi=3 pi=3.0000 pi=3.1415 pi=3.1416 pi=****** 29) Format Code T is used in form of Tn, where transfer of data starts from n-th position relative to the beginning of a record. If the input record is 123456789022222222 then what are the contents M and N after the execution of read statement below? read (*,55)M,N 55 format(T8,I3,T5,I4) a) M = 890 and N = 5678 b) M = 902 and N = 6789 c) M = 123 and N = 4567 d) M = 876 and N = 5432 e) M = 890 and N = 2222 30) What does the following fortran program do? (remember the recitation hours) read*,A,E if(A<=0) goto 20 x=1 50 s=(x+A/x)/2 if(abs(a-s**2)<= e) goto 100 x=s; goto 50 100 print*, '.... of' , a, 'is=',s stop 20 print*,'there is no ... for ', a end a) Finds a real number S between two real numbers A and X. b) Finds Square root of a real number A within a given error E. c) GCD (Greatest Comon Divisor) of real number A. d) Cube root of a real number A. e) It looks like finding the square root of A but depending on E it may find cube root also. A A A A A A A A A A A A A A A A A A A A A A A