Homework –1

The following program contains some errors. Identify the errors and submit corrected version of the program.

Program Homework_

! There are some errors in this program

real : X1-1, Xy2_1, X3 1,X4_

print *''Please type four numbers separated by commas''

Print,''Such as 1,2,3,4 ''

read*, X1-1, xY2_1, X3 1,x4_

!Now print the numbers you typed

print *''The numbers you typed are''

Print*, x1-1, Xy2_1, x3 1,X4_

print *,''Well Done!! ''

End program HoMework_1

Due Date 17 February 2004

 

Homework -2

A body experiencing a uniform acceleration moves a distance ‘s’ in time ‘t’ where ‘s’ is given by

s=(at2/2)+ut

where ‘a’ is the acceleration in [m/s2] and ‘u’ is the initial velocity in [m/s]. Suppose the body is falling freely under gravity with a=g=9.81 [m/s2].

Write a program that asks the user for body’s initial downward velocity in [m/s] and time of flight in [s] and then calculates and prints the height from which the body fell.

i. Make use of the parameter attribute to define gravitational acceleration, g=9.81 [m/s2].

ii. All units in output should be printed out as character constants of appropriate length.

iii. Include a typical output of the program and submit source code and output as hardcopy.

 

Due Date 24 February 2004

Homework -3

Write a program that asks the user to enter the radius of a circle in [m] and calculates and prints the area and circumference of the circle via a subroutine using the following formulae

area =pi x r2 and circumference = 2pi x r

The value of pi used in the subroutine should be defined in a module named constant (make use of parameter and public attributes).

Due Date 9 March 2004

Homework -4

A company sells mobile phones for € 250 each. However, it gives a discount for multiple orders as follows:

Number ordered

Discount [%]

2-9

7

10-29

15

30-99

20

100-299

25

300-499

30

500+

35

 

Write a program to input number of phones required and print the gross cost, the discount (if any), and the net cost.

Make use of the case construct and subroutine procedure in your program.

Due Date 16 March 2004

Homework -5

A researcher measures cartesian components (u,v,w) of velocity at 20 points at a cross-section of a pipe in which a fluid is flowing. He requires a program that declares velocity as a derived type variable, reads velocity from the keyboard and stores it in an array. He also wants the program to calculate and print average of each velocity component and print u component of velocity at intervals of 2 from the array it is stored. The reading, printing and calculations are to be done within a subroutine.

Write a program that solves his problem.

Due Date 30 March2004

Homework -6

Write a program that reads from the keyboard measurements of temperature at 10 different locations (x1, x2, etc.) in Celcius then converts temperature to Fahrenheit using the formula,

F= (9C/5 +32).

Your program should then write the measurement location, temperature in Celcius and temperature in Fahrenheit in a tabulated form into a file. The first record in your file should start at the 10th column and each item is separated by 5 blanks. Include a header for the table in your file and use proper formatting.

Due Date 13.April.2004

Homework -7

The polynomial

63x3-183x2+97x+55

has three real roots between –10 and +10. Write a program to find these roots using the bisection method.

Hint: You must first find intervals in which the roots lie. You can do so by tabulating the value of polynomial for various values of x.

Test your program to find those roots of the following polynomials in the range

–10 x +10.

i. 10x3-x2+69x+72

ii. 20x3-52x2+17x+24

iii. x4-2x3+23x2+24x+144

Due Date 20 April 2004

Homework -8

Using Gaussian elimination method, solve the following equations.

2x+3y+z=4

x-2y-z=3

-2x+y+3z=4

Submit hard and soft copies of your program along with the results of the solution. Make use of formatted output in your program. Your program should write results into a file.

 

Due Date 27 April 2004