Ms 15

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

PH803: Computer Programming and Numerical Methods

Mid-Semester Examination (2015-16)

Maximum Marks 30 Duration: 2 hours


Instructions: Answer Q. 1 to Q. 4 in Answer book. For Q. 5 and Q. 6, you must
write computer programs and run them for credit. The marks of every question are indicated
next to it. At the end of the exam, the TA will collect the Answer book, and the tar les
containing your computer programs.

1. [6 Marks] Find the mistakes in the following Fortran 90 program. By making minimal
changes to the program, print out the values of i from 1 to 5.
program wrong
i m p l i c i t none
integer : : i , integer
i n t e g e r , parameter : : v a l u e
do v a l u e = 1 , i
p r i n t , ' The v a l u e = ' , i
end do
stop
end program wrong
hq
2. [3 Marks] Write Fortran 90 statement for the expression: exp [ 2(x m)2 .
i
1
2

3. [3 Marks] Evaluate 4.10 " 8.43 as accurately as possible..


4. [4 Marks] Consider a function f (x) = x3 3x + 1 in the interval [0, 1]. Find the error
in the root of the function after n = 5 iterations using bisection method. How many
more iterations are needed to reduce the error by half?

5. [6 Marks] Write a Fortran 90 program to compute Kronecker delta i,j , for given values
of i and j . The program should read two integers i and j and print 0 if they are unequal,
and 1 if they are equal.

6. [8 Marks] Write a Fortran 90 program to calculate the square root of a number using
Newton's method. Use the program to calculate the square root of 36 with a starting
value x0 = 5. Calculate only up to x4 .

You might also like