Monday, April 6, 2020

FIRSTWRD.P

[Table of Contents]
Disk Image

FIRSTWRD.P is from Strings And Arrays section of the Kyan Pascal 2.x manual/tutorial. 

What's on the disk?

The disk image includes the various Atari DOS 2.5 files, Kyan Pascal Include files (none of which are used in this program), Kyan Pascal Run-time library, and ...

FIRSTWRD.P - Source code file
P.OUT - Kyan Pascal intermediate file
FIRSTWRD - Executable file

Source Code


(* FirstWrd.p *)
(* Kyan Pascal 2.04 / Atari 8-bit *)

PROGRAM FIRSTWRD(Input,Output);

(* This program requests a list of words, selects the alphabetically
   first word, and counts the number of words entered. *)

CONST
   Signal = '+';

TYPE
   String = ARRAY[1..15] OF Char;

VAR
   Word, LeastWord : String;
   LoopCount : Integer;

BEGIN
(* Each time thrugh the loop, increment the counter,
   LoopCount, and save the least word *)

   Write(Chr(125)); (* Clear screen *)
   Write('Enter a word or "+": ');
   Readln(Word);
   LeastWord:=Word;
   LoopCount:=0;
   WHILE Word[1] <> Signal DO
   BEGIN
      IF Word < LeastWord THEN
         LeastWord:=Word;
      LoopCount:=LoopCount+1;
      Write('Enter a word or "+": ');
      Readln(Word)
   END; (* of the WHILE loop *)

   Writeln;
   Writeln;
   Writeln(LoopCount: 5, ' words were entered.');
   Writeln;
   Writeln(LeastWord:25);
   Writeln;
   Writeln('   is alphabetically first.')
END.

Sample Run



No comments:

Post a Comment