why are data types important?
so that your code knows what kind of information it’s handling
why have data types (3)
categories of data type (3)
primitive data types (3)
data types that represent numbers (4)
on numeric types:
represent mathematical integers; whole numbers
integer
on numeric types:
represent real numbers with decimals
float
on numeric types:
used for double-precision values
double
on numeric types:
represent numbers with real and imaginary parts
complex
on numeric types:
represents exact decimal representation
decimal
boolean has only two values: __ or __
true, false
represents a single character, stored as numeric codes (ASCII, Unicode)
character type
design considerations of character string types (3)
what kind of character string type implementation is show below:
subj = “CMSC 124”
primitive (built-in) type
what kind of character string type implementation is show below:
char str[8];
strcpy(str, “CMSC 124”);
array of char
on string length:
string length is fixed once declare
static length
on string length:
string length can vary but with a limit
limited dynamic
on string length:
string length may change without any limitations
dynamic length strings
dynamic length strings, despite being flexible, must also consider the __
additional overhead
string operations (5)
what string operation is shown below:
“abc” < “bcd” → True
lexical comparison
what string operation is shown below:
Regex r”^[A-Z]{3}\d{3}$”
pattern matching
a homogeneous collection of data in which each element is identified by its position in the collection
array
__ are usually accessed using the array identifier and an index or subscript
array elements