






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!







Q1a[ 8 marks] What is the output from the following Fortran90 program if the values 8, 0, 2, 5 are input in turn at the prompts? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM q1a implicit none integer value, k !---------------------------------------------------- DO k = 1, 4, 1 write(, '(a)', advance='no')'gimmee a value --->' read,value if( (value > 2) .and. (value < 7))then print, 'Wexford' else if(value /= 0)then print, 'Waterford' else print*, 'Cork' end if
if(value == 5)then print, 'Kerry' else if(value >= 3)then value = value + 1 print, 'Limerick' end if END DO !---------------------------------------------------- stop 'q1a ends ...' END PROGRAM q1a
Q1c[ 8 marks] What is the purpose of the following programming? Test it with the values 12, 15, 17, 35 and others if necessary. Find what is IT in each case. Deduce what the code does from your findings. NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM q1c
integer::m, k logical::gotIT = .false. !---------------------------------------------------- write(*,'(A)',advance='no')'gimmee an integer m --->' read *, m
k = 2 do if(k >= m)exit if(mod(m, k) == 0)then gotIT = .true. exit end if k = k + 1 end do print* if(gotIT)then print, 'so there it is --->', k, ' is IT' else print, 'so there is NO IT at all' end if print* !---------------------------------------------------- stop'q1c.f90 ends ...' END PROGRAM q1c
What is the output of the following piece of Fortran90 code?
PROGRAM q1_d implicit none
integer::a, b, c = 7 !------------------------------------------------------------------- do a = c, 1, - do b = c, 1, - if( (a == 1) .or. (a == c) .or. (b == 1) .or. (b == c) )then write(, 12, advance='no')'$' else if(a == b)then write(, 12, advance='no')'' else if(a + b == c + 1)then write(, 12, advance='no')'#' else write(, 12, advance='no')' '!this is a blank end if end do print end do print* print*
12 format(a) !------------------------------------------------------------------- stop'q1_d ends ...' END PROGRAM q1_d
The experimental data for an important experiment are stored in the file f:\myExperiment\myData.dat. The data is raw(without any explanatory text or headings) and each line contains the following data: time, temperature, pressure, volume as shown in fig 2.1 below.
Please write Fortran90 code / program
Write a Fortran90 program to estimate the maximum value of the function ( 2 )
2 2
grid spanning the region. (see Fig 3.1 below)
The code should feature
Q5a(15 marks) Write , in module form, a function reverse(anInteger) to accept an integer as parameter and to return the reverse of that integer
anInteger = 12345 getTheResult = reverse(anInteger) will result in the variable getting the value 54321
Q5b(15 marks) Write, in module form, a function apply(left, symbol, right) which will return the result of applying an operator, symbol , to the real numbers, left and right , The valid operators are