



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Answer Question 1 and two others Examiners: Ms. J. English
Prof. J. Monaghan Mr. J. E. Hegarty
(b) What is the output of the following Fortran90 program for each of the following cases: (i) s Í 35, t Í 7; (ii) s Í 12, t Í 48; (iii) s Í 11, t Í 25? Can you deduce what IT is? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM q1b implicit none
integer:: s, t, r, q !------------------------------------------------------------ --
write(*,'(A)',advance='yes')'gimmee an integer s --->' read , s write(,'(A)',advance='yes')'gimmee an integer t --->' read *, t
do q = s / t r = mod(s, t) if(r == 0)then print*, 'so there it is --->', t, ' is IT' exit end if s = t t = r end do stop'q1b.f90 ends ....' END PROGRAM q1b
(8 marks) (c) Trace the execution of the following code
INTEGER x, y x = 17 y = 23 CALL ProdDiv ( x, y ) PRINT *, x, y END SUBROUTINE ProdDiv ( r, s ) INTEGER r, s, t t = r * s s = r / s r = t RETURN END
(iv) Your program should also allow the user the option of executing the program any number of times for the same or different geometric shapes. ( An Algorithm or a Flowchart must be included ). ( marks)
Simpson’s Rule Quadrature
b
a
f a f x f x f x f x f xn f xn f xn
h f xdx ( ) 4 ( ) 2 ( ) 4 ( ) 2 ( ) .... 2 ( ) 4 ( ) ( ) 3
where: a = x 0 b = x 2 n h = width of each interval ( marks)
(b) Evaluate the quadrature of the following function f(x) between the limits x=0 and x= using Simpson’s rule for (i) with two intervals and (ii) with four intervals.
Comment on the effect of increasing the number of intervals. ( marks)
and the values 1, 2 and 1 have been inputted into array A, what output, if any, is produced by the following code:
DO I = 1, Length = Length + SQRT(A(I)**2) END DO PRINT *,"The value stored in the variable length is ", Length
(3 marks)
2 1
2 f ( x )= 3 x + x −
to compute the distance between two points on a plane together with a driver to test it. The function will have four real numbers as parameters (the x and y coordinates of the two points) and it will return a real value (the distance between the two points). Thus getTheResult = theDistance (0.0, 0.0, 3.0, 4.0) will result in the variable getting the value 5.0.
given by 2 2 1
2 ( y 2 (^) − y 1 ) +( x − x ) and the sqrt() function returns the square root of a real.
( marks)
e.g. coolingState( 65.43) Î ‘ Gleaming’ coolingState(123.45) Î ‘ Dripping’ coolingState( 12.34) Î ‘ Cold’
Cooper’s Social Rules are as follows:
(12 marks)
Temperature°C Cooling Mechanism
over 100o^ Dripping 91 o^ to 100o^ Sweating 81 o^ to 90o^ Perspiring 71 o^ to 80o^ Glowing 61 o^ to 70o^ Gleaming 51 o^ to 60o^ Cool under 50° Cold