Professional Documents
Culture Documents
Task 1:
Attempt the program given in literature above. Also see whether the results are as
expected?
Exercise 1'
Exercise 2'
print*,'2','+','2','=',4
print*,''
print*,''
print*,'
Exercise 3'
print*,'2+2=',4
print*,''
print*,''
print*,'
Exercise 4'
end
AHMED SIDDIQUE
MS-25710
Results:
a=10
b=17
c=20
AHMED SIDDIQUE
MS-25710
print*,''
print*,''
print*,'average of ',a,',',b,'&',c,'is',(a+b+c)/3
print*,''
print*,'
print*,''
print*,''
print*,'Enter lengths:'
read*,length1,length2
print*,''
print*,'The lengths are',length1,'&',length2
print*,''
print*,'
print*,''
print*,''
print*,'Enter the value of a:'
read*,a
print*,'Enter the value of b:'
read*,b
print*,'Enter the value of c:'
read*,c
print*,''
print*,'average of ',a,',',b,'&',c,'is',(a+b+c)/3
print*,''
print*,'
print*,''
print*,''
print*,'Enter the value of angle in degrees:'
read*,angle
print*,'sin (',angle,') =',sin(3.14159*angle/180)
AHMED SIDDIQUE
MS-25710
end
Results:
Task 2:
In the example given in section 4.3, declare another variable named average, save
the average
value in this variable and print this variables value instead of the expression
directly.
MS-25710
Results:
AHMED SIDDIQUE
MS-25710
Task 3:
Checking the order in which mathematical operations are performed in fortran.
AHMED SIDDIQUE
MS-25710
End
Results:
Task 4:
Take the angle from user, compute the trigonometric quantities: sine, cosine,
tangent, sin-1, cos-1, tan-1and print the results in the following format:
sin(angle value) = Computed value
asin(angle value) = Computed value
cos(angle value) = Computed value
acos(angle value) =
Computed value
tan(angle value) = Computed value
atan(angle
value) = Computed value
AHMED SIDDIQUE
MS-25710
read*,z
print*,''
print*,''
x=z*3.14159/180
y1=sin(x)
y2=(180/3.14159)*(asin(y1))
y3=cos(x)
y4=(180/3.14159)*(acos(y3))
y5=tan(x)
y6=(180/3.14159)*(atan(y5))
print*,'sin(',z,') = ',y1,'
asin(',y1,') = ',y2
print*,''
print*,''
print*,'cos(',z,') = ',y3,'
acos(',y3,') = ',y4
print*,''
print*,''
print*,'tan(',z,') = ',y5,'
atan(',y5,') = ',y6
Results:
Task 5:
AHMED SIDDIQUE
MS-25710
Find the hypotenuse of a triangle by taking base and perpendicular from the user.
Print the computed value.
INPUT
print*,'Enter the value of perpendicular in cm:'
print*,''
read*,perp
print*,''
print*,''
print*,'Enter the value of base in cm:'
print*,''
read*,base
Execution
hyp=sqrt(((perp)**2)+(base**2))
Results
print*,''
print*,''
print*,'hypotenuse of triangle with ',perp,'cm perpendicular and'
1,base,'cm base is',hyp
print*,''
end program calculation of hypotenuse of triangle
Results:
AHMED SIDDIQUE
MS-25710
Task 6:
Take input from user the initial number of atoms, half-life and the time that an atom
has spent to calculate the atoms remaining?
INPUT
print*,'Enter the following values:'
print*,''
print*,'initial number of atoms:'
print*,''
read*,no
print*,''
print*,''
AHMED SIDDIQUE
MS-25710
EXECUTION
lamda=0.693/thalf
n=no*(exp(-lamda*t))
RESULTS
print*,'NO. of atoms after ',t,' seconds = ',n
end program Calculation of remaining radioactive atoms
Results:
AHMED SIDDIQUE
MS-25710