x, y, z, r, area: real;
Function N (I, j, k: real): real;
N:=x + y + z / 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);
Logic of The Program
- The global variables have been declared at the top, which are x, y, z, r, and area.
- The Function N defines the variables i, j, k which must be of the same data type (real, integer, string or any other) as the global variables to avoid errors, which in this case, the appropriate type is the real data type.
- Using the formula of N ( N= x + y + z / 2) in the question, the same formula is assigned to N in the program as N:=x + y + z / 2;.
- Next, the user is prompted to enter three numbers which are read in as values for x, y, z.
- These identifiers (x, y, z take the values of I, j, k) and replace the local variables when the Function N is called and assigned to 'r'.
- The latter part of the program calculates the area of the triangle.
BASIC Program For Sum of Numbers Using IF Then Statement