Download
ordinal data types n.
Skip this Video
Loading SlideShow in 5 Seconds..
Ordinal Data Types PowerPoint Presentation
Download Presentation
Ordinal Data Types

Ordinal Data Types

127 Views Download Presentation
Download Presentation

Ordinal Data Types

- - - - - - - - - - - - - - - - - - - - - - - - - - - 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;