Fundamental Data Types Flashcards
What does the data type tell the compiler?
How much memory to set aside for a variable and how to interpret the bits/bytes at a memory address
What is the syntax for explicit vs. implicit assignment
Explicit:
type varName = value;
Implicit: type varName(value);
Is the following syntax correct or incorrect:
int nValue 1, int nValue2;
Incorrect; this will not compile b/c only one type can be specified per line.
T/F: In the following expression the value of ‘nValue 1’ is 5:
int nValue1, nValue2 = 5;
F; nValue 2 contains the value 5, whereas nValue1 is uninitialized
What is a keyword in C++?
An identifier reserved by the language that cannot be reused
What is an identifier?
The name of a function, variable, class, or any entity in C++
What are the rules for creating an identifier?
It cannot be a keyword, must be composed only of letters, numbers, and the underscore character, must begin with a letter or underscore (not a number), is case sensitive, and describes the thing that it identifies.
What is Hungarian notation?
prefixing a variable with an indication of its type: int nValue; bool bValue; char chValue; double dValue; float fValue;
How is memory assigned to a variable with a size larger than 1 byte?
Consecutive memory addresses are used
What is the ‘sizeof()’ operator?
It is a unary operator which returns the size of a type or variable in bytes.
T/F: The size of data types is not consistent across systems
T; The size of any data type is not guaranteed to be a specific value on any given system, although it will likely be close.
What are the four types of integers and their approximate sizes?
char (1 byte)
short (2 bytes)
int (2 or 4 bytes)
long (4 bytes)
T/F: ‘short’ and ‘long’ are shorthand
T; they stand for ‘short int’ and ‘long int’, respectively
How does the signed/unsigned qualification affect the range of an integer?
Unsigned integers cannot store negative values, but can store positive numbers that are twice as large as those stored by a signed integer
What is the definition of an integer?
A data type which holds whole numbers/characters