



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
Information about a bachelor of engineering (honours) in mechanical engineering exam from cork institute of technology, autumn 2006. The exam focuses on computing and numerical methods and includes three hours of questions based on fortran90 programming. The instructions for the exam, including the examiners' names, and includes several fortran90 programs that need to be analyzed or written. The programs cover topics such as logical statements, triangle classification, and statistical analysis.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Instructions: Answer Question 1 and two others Examiners: Ms. J.English Prof. M. Gilchrist Mr. J. E. Hegarty
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.
program q1a implicit none integer :: a = 12, b = 9, c= 8
if ( (b /= 10) .and. (b /= 20) )then if ( 0 /= a)then print, "A" else print, "B" end if end if
a = a + 1 if( (a == b) .and. (b > c) )then print, "C" end if
if( (a <= b) .and. (b <= c) )then print, "D" end if
if(( a < b).or.(b < c )) then print , "E" end if
stop ’q1a is ending …’ end program q1a
What is the output of the following Fortran90 program? Test it with the following inputs 6,4,2 0. NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
program q1b implicit none integer value, k, j logical result
do write(*, '(a)', advance='no')'gimmee a starting value --->' read *, value write( *,15, advance='no') value
if( 0 == value)exit result = (value >= 0) value = abs(value)
do k = value -2, 0, - do j = k, -k, - if (result) then write( *,10, advance='no') j else write( *,10, advance='no') -j end if end do result = .not.(result) end do
print* end do
print*
10 format( i3 ) stop 'q1b ends --->' end program q1b
Write a function that receives a positive integer n and returns true if n is a prime, and false if n is not a prime number. A prime number is a number that is divisible only by itself and 1. For example , if 15 is received, the function returns false; if 13 is received, the function returns true.
The data for this statistical analysis are stored in the file C:\StatsExperiment\myData.dat.The data is raw (without any explanatory text or headings) and each line contains a single x value as shown in fig. 2b_ below. The end of the file is signalled by the number -99. You are required to write a program to connect to this file and perform the following analysis on the data it contains. (i) Count the number of values in the file. (ii) Calculate the mean of the data in the file. (iii) Count the number of values less than the mean value and the number of values greater than the mean value Your program should then output the relevant results to the screen and also output the results to the file C:\StatsExperiment\myResults.dat.
23 27 15 56 48 21 10 18 78 34 89 56 20 17 67 31
fig. 2b_
1
n
i i
Write a Fortran90 function module for the Fortran90 functions FUNCTION f(x) and FUNCTION fPrime(x) To define the functions
y = f ( ) x = 3.5 x^3 − 2.4 x^2 + 3.8 x −2.
dy (^) f | (^) ( ) x 10.5 x (^2) 4.8 x 3. dx
Write a Fortran90 subroutine module to implement the NewtonRaphson Root Finding Algorithm,
Note:
Write a Fortran90 driver program to use the above modules to search for and find the roots of f(x). This program will feature
Write a Fortran90 program that accepts a positive integer N and outputs to the screen the first N powers of 3:
The sequence of Fibonacci numbers begins with the integers
1,1,2,3,5,8,13,21,……..
where each number after the first two is the sum of the two preceding numbers. Write a Fortran90 program that reads a positive integer n and then displays the first n Fibonacci numbers to the screen.
Write a Fortran90 program that will input n integers (the number of values to be entered is to be specified by the user). The program can use –999 as the end-of-input marker. The program should then sort the list of integers in ascending order and output the sorted list to the screen.