Page 158 - DCAP507_SYSTEM_SOFTWARE
P. 158

System Software




                    Notes          C:
                                        Enumerated-type-identifier   (i1, i2, i3,à.in);
                                   enum
                                                             item-list

                                                                     Identifier  for
                                                                     enumerated type
                                                                     reserved word
                                   for example,
                                                enum time of day  {am, pm};
                                   enumerated  data type               item-list

                                   once variables have been declared as enumerated data types, they can only have the values
                                   defined in the item-list. For example,
                                   enum time of day       X,   Y;

                                   enum time of day       X,   Y;
                                   data - type          variables
                                   declares the variables X and Y to be of type time of day and can assume values from the item-list.

                                   Subrange Data Type

                                   When a data  item takes a range of values which is a subrange of the values described by some
                                   existing type i.e. primitive or enumerated, its type may be defined as a subrange of that host
                                   type. The syntax is as follows:
                                   type

                                          type-identifier  =  lowerlimit..upperlimit
                                   where lowerlimit and upperlimit must  be constant, or previously defined constant identifier
                                   (of type integer) or item of an enumerated-type-list. Moreover, lowerlimit is always less than
                                   the upperlimit.


                                          Example: of subrange type declaration are:
                                   const
                                   M = 15;
                                   N = 2;
                                   type
                                   VALUE = 'N'.. 'M' ;

                                   NUMBER = 1..100 ;
                                   LETTER = 'A'.. 'Z' ;
                                   Variables of these type may be declared as
                                   Var
                                   RESULT,  answer : NUMBER;





          152                               LOVELY PROFESSIONAL UNIVERSITY
   153   154   155   156   157   158   159   160   161   162   163