Pascal program To Calculate Area of a Triangle

Write a pascal program that uses a function subprogram called N to calculate the area of a triangle with the formula: Area=√N(N-X)(N-Y)(N-Z) where N= x + y + z / 2

Program area_Of_triangle;
x, y, z , r, area : real;
Function N (I, j, k: real): real;
N:=a + b + c / 2;
Writeln (' enter values for  x, y, z');
Readln (x, y, z);
r := N(x, y, z);
Area:= sqrt( r- x)*(r-y)*(r-z);
Writeln ('Area:', area);

The global variables have been declared at the top which is x, y, z. The function carries the local variables i, j, k which must be of the same type as the global variables (real, integer, string or any other). But in this case, the appropriate type is a real data type.

Using the formula of N in the question, this formula isassigned to N in the program.

Next the values are read in by the user which is prompted by 'enter the values for x, y, z'. These identifiers (x, y, z take the values of I, j,k) replace the local variables when the is function N is called and assigned to 'r'. The later part to the program calculates the area of the triangle.

Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:

HTML Link Code:

BB (forum) link code:

Share on Google Plus

About Grace Joseph

Grace Joseph is an educational and tech blogger. Other than having passion for gadgets and generally the tech niche, she's a writer at heart and reading is forever a hobby.


Post a Comment