Tuesday, March 31, 2015

Write a Fortran Programme find area and input three point of Triangle


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
!Author:Md. Abde Mannaf
!any point given and putting value
!The program finds area of triangle & input point
program area_triangle
implicit none

real::area,s,sqrt,x1,y1,x2,y2,x3,y3,p,a,b,c
print*,'enter the value of three sides of triangle x1,y1'
read*,x1,y1

print*,'enter the value of three sides of triangle x2,y2'
read*,x2,y2

print*,'enter the value of three sides of triangle x3,y3'
read*,x3,y3

a=sqrt((x2-x1)**2+(y2-y1)**2)
b=sqrt((x3-x2)**2+(y3-y2)**2)
c=sqrt((x1-x3)**2+(y1-y3)**2)

if(a+b>c .and. b+c>a .and. c+a>b) then
s=(a+b+c)/2
area=sqrt(s*(s-a)*(s-b)*(s-c))
print*,'area of triangle =',area
p=2*s
print*,'perimeter is=',p
else
print*,'triangle is not valid '

end if

end program area_triangle

No comments:

Post a Comment