Page 157 - DCAP507_SYSTEM_SOFTWARE
P. 157

Unit 10: Programming Languages Concept (I)




          The type boolean                                                                      Notes

          This type allows only two values true or false. So a boolean variables can assume one of two
          values true or false.

          The type double

          It is an advancement of the type float.  In this case, the length of signed or unsigned decimal
          numbers can be larger than that of float type.  These are called as double precision numbers.


                 Example: of this data type are:
          23512.6732469,  -6712345.98765

          10.3.2 User-defined Data Types

          Both languages provide facilities for declaring and defining new data types by the user.
          In PASCAL, these are:
          (i)  Enumerated data type

          (ii)  Subrange data type
          In case of language C, these are:
          1.   Enumerated data type
          2.   By using typedef statement

          Enumerated Data Type

          An enumerated data type is a user created data type in which the values, appropriate to the
          datatype, are specified in a user-defined list.  The syntax is:
          PASCAL:
          Type Enumerated-type-identifier   (i1, i2, i3,à.in);
                Type                  :     Reserved word
          Enumerated-type-identifier  :     Identifier
          i1, i2, i3,à.in             :     Item list

          The item-list constitutions the allowed values which the enumerated type variable can assume.
          For example,
          Type
          MONTHS= (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC);
          Enumerated data type                    item list

          Now, variables of type MONTHS can be defined as
          Var A, B, C: MONTHS;
          Thus A, B & C can have the values defined by the item-list.








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