CALC.ATR Disk Image
CALC.P is from the SCOPE section of the Kyan Pascal 2.x User's Manaul.
What's on the disk?
The disk image includes the various Atari DOS 2.5 files, Kyan Pascal Include files, Kyan Pascal Run-time library, and ...
CALC.P - Source code file
P.OUT - Kyan Pascal intermediate file
CALC - Executable file
Source Code
(* CALC.P *)
(* Kyan Pascal / Atari 8-bit *)
PROGRAM CALC(Input,Output);
VAR
Pick : Char;
X, Y, Answer : Real;
PROCEDURE Choice(Select : Char; N1, N2 : Real);
FUNCTION Sum(Val1, Val2 : Real) : Real;
BEGIN
Sum := Val1 + Val2
END;
FUNCTION Average(Val1, Val2 : Real) : Real;
CONST
D = 2;
BEGIN
Average := (Val1 + Val2) / d
END;
FUNCTION Difference(Val1, Val2 : Real) : Real;
BEGIN
Difference := Val1 - Val2
END;
BEGIN (* of Procedure containing nested Functions *)
CASE Select OF
'S' : Answer := Sum(N1,N2);
'A' : Answer := Average(N1,N2);
'D' : Answer := Difference(N1,N2);
END (* of CASE *)
END; (* of PROCEDURE *)
BEGIN (* of Program *)
Writeln;
Writeln;
Writeln('This program computes the Sum,');
Writeln('Average, or Difference of two numbers.');
Writeln;
Writeln;
Writeln('Enter S, A, or D: .');
Readln(Pick);
Writeln;
Write('Enter the first number: ');
Readln(X);
Writeln;
Write('Enter the second number: ');
Readln(Y);
Writeln;
Choice(Pick, X, Y); (* Call Choice Procedure *)
Writeln;
If Pick = 'S' Then
Writeln('The sum is ', Answer:5:2);
If Pick = 'A' Then
Writeln('The Average is ', Answer:5:2);
If Pick = 'D' Then
Writeln('The Difference is ', Answer:5:2)
END.
No comments:
Post a Comment