1 / 10

Ordinal Data Types

Ordinal Data Types. CSCE 110. Data Types. structured. simple. pointer. ordinal. real. array. record. set. file. predefined. programmer-defined. predefined. programmer-defined. integer. char. boolean. enumerated. subrange. text. Type Declarations. type name-1 = type-1 ;

tilly
Download Presentation

Ordinal Data Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ordinal Data Types CSCE 110

  2. Data Types structured simple pointer ordinal real array record set file predefined programmer-defined predefined programmer-defined integer char boolean enumerated subrange text

  3. Type Declarations type name-1 = type-1; name-2 = type-2; . . . name-m = type-m;

  4. Type Declaration Examples type filename_type = array[256]; logical_type = boolean; var filename: filename_type; p, q, r: logical_type;

  5. Enumerated Type • Purposes • More _____________________ code • _______ prevention ( ident-1, ident-2, … ident-n )

  6. Enumerated Type Example type daysOfWeek = (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday ); var day:daysOfWeek;

  7. Enumerated Type Example for day:=Sunday to Saturday do case day of Sunday: writeln('Sunday'); Monday: writeln('Monday'); Tuesday: writeln('Tuesday'); Wednesday: writeln('Wednesday'); Thursday: writeln('Thursday'); Friday: writeln('Friday'); Saturday: writeln('Saturday'); end

  8. Ordinal Type Operations • Enumerated types, integer, char, & boolean • _____ • _____ • _____ • <, <=, =, >=, <>

  9. Subrange Type • Purposes • _______ prevention • Generalization of _________________ type (i.e. simpler to write) first-value..last-value

  10. Subrange Type Example type digit_type = '0'..'9'; capitalLetters_type = 'A'..'Z'; lowerCaseLetters_type = 'a'..'z'; var cents: 0..99; daysInMonth: 28..31; bigLetter: capitalLetters_type; smallLetter: lowerCaseLetters_type;

More Related