Computing and Numerical Methods Exam for Mechanical Engineering Students - Summer 2005, Exams of Mathematical Methods for Numerical Analysis and Optimization

The exam questions and instructions for the computing and numerical methods module of the mechanical engineering degree at cork institute of technology, held in summer 2005. The exam covers various topics such as arithmetic operators precedence in fortran, fortran90 programming, code execution, and temperature conversion. Students are required to answer specific questions related to these topics.

Typology: Exams

2012/2013

Uploaded on 04/13/2013

pannaaaa
pannaaaa 🇮🇳

4.8

(6)

68 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Cork Institute of Technology
Bachelor of Engineering (Honours) in Mechanical Engineering – Stage 1
Bachelor of Engineering in Mechanical Engineering – Stage 1
(NFQ – Level 8)
Summer 2005
Computing and Numerical Methods
Time: 3 Hours
Answer Question 1 and two others Examiners: Ms. J. English
Prof. J. Monaghan
Mr. J. E. Hegarty
pf3
pf4
pf5

Partial preview of the text

Download Computing and Numerical Methods Exam for Mechanical Engineering Students - Summer 2005 and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Engineering (Honours) in Mechanical Engineering – Stage 1

Bachelor of Engineering in Mechanical Engineering – Stage 1

(NFQ – Level 8)

Summer 2005

Computing and Numerical Methods

Time: 3 Hours

Answer Question 1 and two others Examiners: Ms. J. English

Prof. J. Monaghan Mr. J. E. Hegarty

  1. (a) List the order of precedence of the arithmetic operators in FORTRAN. What will FORTRAN evaluate the following expressions to be? i. 2.3/6 + 5.7/4 + 3.7/2 -2.1/4. ii. –(3.5)** iii. 43 iv. 32+4.0/4+83+5/(2*2) v. -5.0 ** 3.0 (8 marks)

(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)

  1. (a) Write a subroutine called SIMP to evaluate the quadrature of f(x) using Simpson’s rule where

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)

  1. (a) Assuming that the following declarations have been made: REAL :: A(3), Length INTEGER :: I

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)

  1. (b) Write an internal function theDistance()

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.

Note: The distance between the two points (^ x^1^^ ,^ y^1 )and (^ x^2^^ ,^ y^2 )is

given by 2 2 1

2 ( y 2 (^) − y 1 ) +( xx ) and the sqrt() function returns the square root of a real.

( marks)

  1. (c) Write a function coolingState(yourTemperature) which will return the result of applying Cooper’s Social Rules(detailed in the table below) to your temperature in °C. Include with it a driver program to test it.

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