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 |
Tuesday, March 31, 2015
Write a Fortran Programme find area and input three point of Triangle
Subscribe to:
Post Comments (Atom)
This is a really clean and straightforward Fortran program for calculating the area of a triangle using coordinate points and Heron's formula. Checking the validity of the triangle with the if statement before doing the square root is an excellent practice to avoid runtime errors! For students who are just starting to learn computational logic or finding it tough to debug their university code, getting reliable Fortran assignment help in the UK can be an absolute lifesaver for mastering these kinds of programming tasks. Thanks for sharing this helpful example
ReplyDelete