W2: TYPES Flashcards
_ Fundamental Types
W2-Q1: What is the type of a region of memory used for?
_ defines how to interpret the bit string in that region
_ defines the operations that are admissible on that region
W2-Q2: List 2 FUNDAMENTAL types of C++ core language?
_ INTEGER types and FLOATING-POINT types
W2-Q3: The INTEGER types consist of which types?
_ standard integers 1/ signed standard integers 2/ unsigned standard integers _ booleans: 1 byte: true or false _ character types: to represent the dif. language symbols
W2-Q4: Range specifiers on the standard integer types set the ranges of values associated w/t 2 types. What are they?
_ signed - negative and positive values
_ unsigned - NO negative values
W2-Q5: C++17 defines 5 SIGNED standard integer types: What are they?
_ signed char: hold negative and positive values; ocupies 1 byte to store the language’s BASIC character setX
_ short int (a short): btw a SIGNED char + an int (16 bits)
_ int: btw a SHORT int + LONG int (32 bits)
_ long int (a long): btw int + LONG LONG int (32 bits)
_ long long int (a long long) (64 bits)
_ short, long, or long long (before int) => size specifier
W2-Q6: Characteristics of SIGNED char
_ to read input from a file and trap the end of file mark (EOF = -1)
signed char c; // for possibly receiving EOF
_ define a constant of signed char type using single quotes around char, oct, or hex notation:
EX: signed char k, m, n, p;
k = ‘[’; // character
m = ‘\133’; // octal - note the leading \
n = ‘\x5b’; // hexadecimal - note the leading \x
p = ‘\X5B’; // hexadecimal - note the leading \X
_ The single quotes identify a character literal.
W2-Q7: Characteristics of int
define a constant of int type using dec, oct or hex notation:
EX: int a, b, c, d;
a = 91; // decimal
b = 0133; // octal - note the leading 0
c = 0x5b; // hexadecimal - note the leading 0x
d = 0X5B; // hexadecimal - note the leading 0X
W2-Q8: Characteristics of long int
define a constant of long int type using dec, oct, or hex notation with the suffix L or l
EX: long int a, b, c, d;
a = 91L; //long: L or l
b = 0133L; // octal - long: L or l
c = 0x5bL; // hexadecimal - long: L or l
d = 0X5BL; // hexadecimal - long: L or l
W2-Q9: Characteristics of long long int
define a constant of long long int type using decimal, octal, or hexadecimal notation with the suffix LL or ll
EX: long long int a, b, c, d;
a = 91LL; // long: LL or ll
b = 0133LL; // octal - long: LL or ll
c = 0x5bLL; // hexadecimal - long: LL or ll
d = 0X5BLL; // hexadecimal - long: LL or ll
W2-Q10: Characteristics of UNSIGNED standard integers
_ use UNSIGNED types for variables that only hold NON-NEGATIVE values
EX: unsigned char letter;
unsigned short int languages;
unsigned int persons;
unsigned long int students;
unsigned long long int citizens;
_ identify an UNSIGNED constant using decimal, octal, or hexadecimal notation with the suffix U or u:
unsigned int g;
unsigned long int h;
unsigned long long int k;
g = 0x5bU; // unsigned int: U or u
h = 0X5BUL; // unsigned long: (U or u) and (L or l) any order
k = 456789012345ULL; // unsigned long long: (U or u, LL or ll) any order
W2-Q11: List 6 CHARACTER types
_ char _ signed char _ unsigned char _ wchar_t _ char16_t _ char32_t
W2-Q12: What is a LOCALE?
A LOCALE identifies the set of features that are CULTURE-specific.
W2-Q13: What is a wchar_t type? What is the UNDERLYING type?
_ wchar_t type is a wide character type that can store all of the members of the LARGEST character set amongst the supported LOCALES
_ UNDERLYING TYPE: wchar_t type has the SAME amt of memory and signedness as one of the other integral types
W2-Q14: Characteristics of wchar_t type
_ define a constant of wchar_t type using the prefix L followed by single quotes around char, oct, or hex notation:
wchar_t k, m, n, p;
k = L’[’; // character - note the leading L
m = L’\133’; // octal - note the leading L’\
n = L’\x5b’; // hexadecimal - note the leading L’\x
p = L’\X5B’; // hexadecimal - note the leading L’\X
W2-Q15: What is char16_t type? Characteristics of char16_t type?
_ The char16_t type is a character type for representing characters using UTF-16.
_ define a constant of char16_t type using the prefix u followed by single quotes around character, octal, or hexadecimal notation:
char16_t k, m, n, p;
k = u’[’; // character - note the leading u
m = u’\133’; // octal - note the leading u’\
n = u’\x5b’; // hexadecimal - note the leading u’\x
p = u’\X5B’; // hexadecimal - note the leading u’\X