Pascal program To Calculate Area of a Triangle andrey пятница, 11 апреля 2014 г. No Comment

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;
Var
x, y, z , r, area : real;
Function N (I, j, k: real): real;
Begin
N:=a + b + c / 2;
End;
Begin
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);
Readln
End.
 

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.

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;
Var
x, y, z , r, area : real;
Function N (I, j, k: real): real;
Begin
N:=a + b + c / 2;
End;
Begin
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);
Readln
End.
 

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.

by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment