



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Exam questions from a computing and numerical methods module for students of mechanical engineering at cork institute of technology. The questions involve writing and debugging fortran90 programs, including calculating quotients and remainders, implementing function modules, and using the bisection root finding algorithm.
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Instructions: Examiners: Ms. J. English Answer Question 1 and two others Mr. P. Clarke Prof. M. Gilchrist
What output is produced from the following Fortran90 program given the following input values 7,9,6,5? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM a2007_q1a implicit none integer value, k !---------------------------------------------------- DO k = 1, 4, 1 write(, '(a)', advance='no')'gimmee a value --->' read,value if( (value > 3) .and. (value < 8))then print, 'Meath' else if(value /= 0)then print, 'Galway' else print, 'Cork' end if if(value == 6)then print, 'Kerry' else if(value >= 4)then value = value + 1 print*, 'Wicklow' end if END DO !----------------------------------------------------
stop 'a2007_q1a has now ended …' END PROGRAM a2007_q1a
What is the output of the following Fortran90 program? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
What is the output of the following Fortran90 program for the inputs 14, 17, 33, 11 Deduce the purpose for the code?. NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM a2007_q1b
implicit none
integer :: m,n,p
p = 5
do m = 1,p, do n = m,p, 2 if((m == 1).or.(m == p).or.(n == m).or.(n == p)) then write(,'(i1)',advance = 'no') n else write(,'(a)',advance = 'no') '*' end if end do print * end do !------------------------------------------------------------------- stop 'q1_b.f90 ends ...'
END PROGRAM a2007_q1b
PROGRAM a2007_ q1c implicit none PROGRAM q1c integer:: r, t logical:: gotIT = .false. !---------------------------------------------------- write(,'(A)',advance='no')'gimmee an integer r --->' read , r t = 2 do if (t >= r)exit if (mod(r, t) == 0)then gotIT = .true. exit end if t = t + 1 end do print if (gotIT) then print, 'so there it is --->', t, ' is IT' else print, 'so there is NO IT at all' end if print stop ' a2007q1c.f90 ends ...' END PROGRAM a2007_ q1c
The distribution of overtime earnings for 200 operatives during the first quarter of 2006 are stored in the file inData.txt. The data is raw (without any explanatory text or headings) and each line contains the following data: x f as shown in fig. 2.1 below. We use x to represent the overtime amount and f to represent the frequency of this value.
Please write a Fortran90 program to connect to the file, to read the data and to transfer them to the new file Results.dat in tabular form as shown in fig 2.2 and append below the table details of the mean, the standard deviation and the variance of the overtime earnings as shown in fig 2.
The relevant formulae are also included.
2 2
Q3a[ 6 marks] Write a Fortran90 function module^ for the Fortran90 functions
to the functions
3
Q3b[ 12 marks] Write a Fortran90 function module to implement the Bisection Root Finding Algorithm, SUBROUTINE BISECTION(a,b,eps) given
Q3c[ 12 marks] Write a Fortran90 driver program to use the above modules to search for and find the roots of f(x). This program will feature
Q4a[ 12 marks] Write a menu-driven program that allows the user to convert measurements either from miles to kilometers (1 mile = 1. kilometers), from feet to meters ( 1 foot = 0.3048 meter), or from degrees Fahrenheit to degrees Celsius (C = (5/9)(F – 32)). A sample run of the program should proceed as follows:
Available options are:
Enter an option (1 to see menu): 1 Available options are:
Enter an option (1 to see menu): 3 Enter miles: 12 This is equivalent to 19.31 kilometers
Enter an option (1 to see menu): 2 Enter number of feet: 6 This is equivalent to 1.83 meters
Enter an option (1 to see menu): 5
Q4b[ 8 marks Write a SUBROUTINE that accepts two positive integers M and N and returns an array containing the first N powers of M e.g. if m = 6 and n = 5 the program should return the following values: 1 2 3 4 5
Q4c[ 10 marks]