Just came across a program I wrote then in school to calculate area of triangle using Hero’s formula.
Program flowchart |
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> */ <br /><br />Program AreaOfTriangle;<br />const<br />PI = 3.142;<br />type<br />r=array [1..3] of real; {hold the values of sides of triangle}<br />var<br />d:r;<br />A:real;<br />K:integer;<br />s:real;<br />begin<br /> For k:= 1 to 10 Do {loop for the 10 sets of values}<br /> begin<br /> writeln ('Enter Values of first side');<br /> read (d[1]);<br /> writeln ('Enter Values of second side');<br /> read (d[2]);<br /> writeln ('Enter Values of third side');<br /> read (d[3]);<br /> s:= (d[1]+d[2]+d[3])/2; {compute s}<br /> A:= Sqrt(s*((s-d[1])*(s-d[2])*(s-d[3]))); {compute area}<br /> writeln ('Area = ', A);<br /> end<br />end. <br /> |
1 Comment
gabisa gila