Chapter 3: Directive, Enum, Pointers and Structurs Flashcards
Given the following code, the default value of SEASON.SPRING is _.
enum SEASON { WINTER, SPRING, SUMMER, FALL }
1
What is the difference between a #define constant and const?
define constants are handled by the preprocessor.
Which defines a macro that describes how to perform a multiplication operation between to values?
define multiply(x, y) (x*y)
define WIDTH 80
Given the following code, which statement is correct?
it defines the identifier WIDTH that represent a integer token string 80
Which of the following is a pointer that points to the memory address of a value of double type?
double *dp;
Which is the correct way to declare a pointer variable named “chp” for the following array?
char c[5];
int *chp = c;
If a pointer “ptr” is of integer type which is referencing the two variables of integer type one by one, then it will get the address of __.
The second variable
Which of the following can access the first index of single dimensional array of integer pointers “ptr”?
cout «_space;ptr[0];
Given the following structure definition, which is the correct way to access an element “name”?
struct Employee
{
string name;
string gender;
};
Employee Emp;
Emp.name;
Given the following structure definition, which can create an array of the structure with 20 elements?
struct Employee
{
string name;
string gender;
};
Employee emp[20];
What will be the output of the following C++ code?
enum Color { RED, GREEN, BLUE };
Color c = GREEN;
cout «_space;c;
1
By default, what is the starting value of the first enumerator in an enum type?
0
In C++, which operator is used to declare a pointer?
*
Which of the following statements is true about the “#include” directive in C++?
It is used to include the contents of one file into another during the compilation process.
Given the following, which statement is correct?
int x = 10;
int *ptr = &x;?
x stores a value, ptr stores a memory address.
What is the correct way to declare a pointer to an integer in C++?
int *ptr;
What is the purpose of the delete keyword in C++ in relation to pointers?
To deallocate memory previously allocated with new.
Which can declare a C++ enumeration named “Colors” with values Red, Green, and Blue?
enum Colors { Red, Green, Blue };
By default, what integer values are assigned to the enumerators in a C++ enumeration?
Values starting from 0 and incrementing
Which of the following statements is true regarding the initialization of a struct in C++?
A struct can be initialized using curly braces {}