Data Representation Flashcards
What is the purpose of a user-defined data type?
-To create a new data type.
-To allow data types not available in a programming language to be constructed.
Why user-defined data types necessary?
-No suitable data type is provided by the language used.
-The programmer needs to specify a new data type
…that meets the requirement of the application
What is meant by a user defined data type?
-Derived from on or more existing data types.
-Used to extend the built-in data types.
-Creates data types specific to applications.
Define a non-composite data type.
A data type defined without reference to another data type.
Define enumerated data type.
A data type that has an ordered list of possible values.
Define a data type that holds the set of prime numbers below 20.
TYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19)
Define composite data type.
A data type defined with reference to another data type.
Ex:
TYPE User
DECLARE Name : STRING
DECLARE DateOB: DATE
DECLARE Telephone: INTEGER
ENDTYPE
Define pointer data type.
A user-defined non-composite data type that points to a memory location.
Declare a data type that points to a day of the week.
TYPE TDayPointer = ^STRING // ^DayOfWeek
Define a set
A set is a given list of unordered elements that can use set theory operations such as intersection and union.
Create a set named letter of type char. The declare a variable to hold the vowels of the type of the set.
TYPE letter = SET OF CHAR
DEFINE vowel (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) : letter
What happens when you want to represent a number that occpuies 10 bits with 8 bits. (2 marks)
-Bits have to be truncated in order to represent a number with fewer bits than their starting ones.
-Therefore precision is lost.
What is underflow?
It occurs after an arithmetical/logical operation when the result is too small to be precisely represented in the available system.
Match the files to their corresponding types (sequential, random or serial): “Text file” ;”File for recording temperature every hour” ; “Master file for paying each employee every month”; “Customer user name and password file”
Text file (serial)
File for recording temperature every hour(serial)
Master file for paying each employee every month(sequential)
Customer user name and password file(random)
What is a sequential file (max 5)
-In a sequential file records are stored in a particular order.
-The order is determined based on the value in a key field.
-Records are accessed one after the other.
-Records can be found by searching from the beginning of the file record by record
…Until the record is found or key value is exceeded.