W2: TYPES Flashcards

_ Fundamental Types

1
Q

W2-Q1: What is the type of a region of memory used for?

A

_ defines how to interpret the bit string in that region

_ defines the operations that are admissible on that region

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

W2-Q2: List 2 FUNDAMENTAL types of C++ core language?

A

_ INTEGER types and FLOATING-POINT types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

W2-Q3: The INTEGER types consist of which types?

A
_ standard integers
 1/ signed standard integers
 2/ unsigned standard integers 
_ booleans: 1 byte: true or false
_ character types: to represent the dif. language symbols
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

W2-Q4: Range specifiers on the standard integer types set the ranges of values associated w/t 2 types. What are they?

A

_ signed - negative and positive values

_ unsigned - NO negative values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

W2-Q5: C++17 defines 5 SIGNED standard integer types: What are they?

A

_ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

W2-Q6: Characteristics of SIGNED char

A

_ 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

W2-Q7: Characteristics of int

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

W2-Q8: Characteristics of long int

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

W2-Q9: Characteristics of long long int

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

W2-Q10: Characteristics of UNSIGNED standard integers

A

_ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

W2-Q11: List 6 CHARACTER types

A
_ char
_ signed char
_ unsigned char
_ wchar_t
_ char16_t
_ char32_t
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

W2-Q12: What is a LOCALE?

A

A LOCALE identifies the set of features that are CULTURE-specific.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

W2-Q13: What is a wchar_t type? What is the UNDERLYING type?

A

_ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

W2-Q14: Characteristics of wchar_t type

A

_ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

W2-Q15: What is char16_t type? Characteristics of char16_t type?

A

_ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

W2-Q16: What is char32_t type? Characteristics of char32_t type?

A

_ The char32_t type is a character type for representing characters using UTF-32
_ define a constant of char32_t type using the prefix U followed by single quotes around character, octal, or hexadecimal notation:
char32_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

17
Q

W2-Q17: 3 fundamental types for floating-point values

A

_ float - a single-precision, floating-point number (4 bytes)
_ double - a double-precision, floating-point number (8 bytes)
_ long double - a double-precision, floating-point number, possibly w/t extra precision (8 bytes)
_ not specify the sizes of the float, double or long double type.

18
Q
#W2-Q18: What is a VOID type? 
_ Objects of type VOID are NOT allowed. True or False?
_ What is a VOID type used for?
A

_ The VOID type is an INCOMPLETE type
(A type is INCOMPLETE if it is missing some INFO)
_ TRUE
_ the RETURN type of functions that do NOT return any value and for generic pointers

19
Q

W2-Q19: How can a variable be initialized at its declaration?

A

_ by copying the initial value using the assignment operator
_ by appending the braces-enclosed value to the declaration
_ by equating the declaration to a braces-enclosed value

20
Q

W2-Q20: What is the keyword auto used for?

A

_ specifying INFERENCE.
_ The compiler can INFER the type from the right operand of an initializer expression.
_ auto cannot appear in the top-level declaration of an array type

21
Q

W2-Q21: How can we specify the ALIGNMENT of an object type?

A

_ using alignas().

_ The alignof() operator returns the ALIGNMENT requirement of its argument type.