0% found this document useful (0 votes)
257 views3 pages

FORTRAN90 - Practical Exercises: Session - 1

The document contains 16 questions related to practical exercises in Fortran90 programming. The questions cover topics such as expressions, control structures, arrays, intrinsic functions, subroutines, functions, modules, and complex arithmetic. The goal is to write programs that perform tasks like calculating circle/sphere properties, triangle classification, vector conversion to Cartesian coordinates, number conversion to Roman numerals, and array operations.

Uploaded by

Ahmad Abba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
257 views3 pages

FORTRAN90 - Practical Exercises: Session - 1

The document contains 16 questions related to practical exercises in Fortran90 programming. The questions cover topics such as expressions, control structures, arrays, intrinsic functions, subroutines, functions, modules, and complex arithmetic. The goal is to write programs that perform tasks like calculating circle/sphere properties, triangle classification, vector conversion to Cartesian coordinates, number conversion to Roman numerals, and array operations.

Uploaded by

Ahmad Abba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

FORTRAN90 - Practical Exercises

Session -1

Question 1: (Expressions)

Rewrite the following expression so that it contains the equivalent symbolic relational
operators and then ad d parenthesis to ind icate the ord er of evaluation,

.NOT.A.AND.B.EQV.C.OR.D.AND.E.OR.x.GT.y.AND.y.eq.z

Ad d parenthesis to this expression to ind icate the ord er of evaluation,


-a*b-c/d **e/f+g**h+1-j/k

Question 2: (Control structures)

Write a simple program to read in the rad ius and calculate the area of the correspond ing
circle and volume of the sphere.
(Use the statements: DO, PRINT and READ. And , the value of PI is 3.14159 )

Question 3: (Control structures, Intrinsic fucntions)

Write a program to accept three (INTEGER) lengths and report back on whether these
lengths could d e ne an equilateral, isosoles or scalene triangle (3, 2 or 0 equal length sid es)
or whether they cannot form a triangle.

Question 4: (Control structures, Functions)

Write a program to read in a vector d e ned by a length, r and an angle, , in d egrees which
prints out the correspond ing (x; y) co-ord inates. Recall that arguments to trigonometric
functions are in rad ians.

Question 5: (Control structures)

Using a SELECT CASE block and integer d ivision write a program that read s in a d ecimal
number between 0 and 9 9 9 and prints out the equivalent in Roman Numerals.

Question 6: (Arrays - Rank, Extents etc.)

Give the rank, bound s, size and shape of the arrays d e ned as follows:
REAL, DIMENSION(1:10) :: ONE
REAL, DIMENSION(2,0:2) :: TWO
INTEGER, DIMENSION(-1:1,3,2) :: THREE
REAL, DIMENSION(0:1,3) :: FOUR

Question 7: (Arrays - Conformance)

Given
REAL, DIMENSION(1:10) :: ONE
REAL, DIMENSION(2,0:2) :: TWO
INTEGER, DIMENSION(-1:1,3,2) :: THREE
REAL, DIMENSION(0:1,3) :: FOUR

Which two of the arrays are conformable?

Question 8: (Array sections)

Declare an array of rank 3 which might be suitable for representing a hotel with 8 floors and
16 rooms on each floor and two bed s in each room. How would the second bed in the 5th
room on floor 7 be referenced ?

Question 9: (Array Element Ord ering)

Given
REAL, DIMENSION(1:10) :: ONE
REAL, DIMENSION(2,0:2) :: TWO
INTEGER, DIMENSION(-1:1,3,2) :: THREE
REAL, DIMENSION(0:1,3) :: FOUR

Write d own the array element ord er of each array.

Question 10: (Array Sections)

Declare an array which would be suitable for representing a chess board . Write a program to
set all the white squares to zero and the black squares to unity. (A chess board is 8x8 with
alternate black and white squares)

Question 11: (MATMUL Intrinsic)

For the d eclarations:


REAL, DIMENSION(100,100) :: A, B, C

what is the d ifference between C=MATMUL(A,B) and C=A*B?


Session – 2

Question 12: (Simple subroutines)

Write a main program and internal subroutine that returns, as its rst argument, the sum of
two real numbers.

Question 13: (Simple functions)

Write a main program and an internal function that returns the sum of two real numbers
supplied as arguments.

Question 14: (Internal functions - Stand ard d eviation)

Write a program which contains an internal function that returns the stand ard d eviation from
the mean of an array of real values. Note that if the mean of a sequence of values (xi ; i = 1;
n) is d enoted by “m” and the stand ard d eviation is d enoted by “s”.

[Hint: In Fortran 9 0 SUM(X) is the sum of the elements of X.]

Question 15: (Mod ules)

Write a mod ule containing a function which returns the position of a particular number in an
array of sorted integers.

Question 16: (Mod ules – Complex arithmetic)

Write a MODULE called Integer Complex Arithmetic which contains 4 FUNCTIONs each
accepting two integer complex number `operand s' and d elivering the result of ad d ition,
subtraction, multiplication and d ivision. (Hint: Use d erived d ata types)

You might also like