VMS Help
PASCAL, Statements, REPEAT, Examples

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

     REPEAT
        READ (x);
        IF (x IN ['0'..'9'])
        THEN
           BEGIN
           Digit_count := Digit_count + 1;
           Digit_sum := Digit_sum + ORD (x) - ORD ('0');
           END
        ELSE
           Char_count := Char_count + 1;
     UNTIL EOLN (INPUT);

  Assume that the variable 'x' is of type CHAR and  the  variables
  'Digit_count',  'Digit_sum',  and  'Char_count' denote integers.
  The example reads a character (x).  If the value  of  'x'  is  a
  digit,  the count of digits is incremented by one and the sum of
  digits is increased by the value of 'x', as computed by the  ORD
  function.   If  the  value  of  'x' is not a digit, the variable
  'Char_count' is incremented by one.  The REPEAT  loop  continues
  processing characters until it reaches an end-of-line condition.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.