Chapter 3: Directive, Enum, Pointers and Structurs Flashcards

1
Q

Given the following code, the default value of SEASON.SPRING is _.

enum SEASON { WINTER, SPRING, SUMMER, FALL }

A

1

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

What is the difference between a #define constant and const?

A

define constants are handled by the preprocessor.

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

Which defines a macro that describes how to perform a multiplication operation between to values?

A

define multiply(x, y) (x*y)

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

define WIDTH 80

Given the following code, which statement is correct?

A

it defines the identifier WIDTH that represent a integer token string 80

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

Which of the following is a pointer that points to the memory address of a value of double type?

A

double *dp;

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

Which is the correct way to declare a pointer variable named “chp” for the following array?

char c[5];

A

int *chp = c;

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

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

A

The second variable

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

Which of the following can access the first index of single dimensional array of integer pointers “ptr”?

A

cout &laquo_space;ptr[0];

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

Given the following structure definition, which is the correct way to access an element “name”?

struct Employee
{
string name;
string gender;
};

Employee Emp;

A

Emp.name;

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

Given the following structure definition, which can create an array of the structure with 20 elements?

struct Employee
{
string name;
string gender;
};

A

Employee emp[20];

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

What will be the output of the following C++ code?

enum Color { RED, GREEN, BLUE };
Color c = GREEN;
cout &laquo_space;c;

A

1

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

By default, what is the starting value of the first enumerator in an enum type?

A

0

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

In C++, which operator is used to declare a pointer?

A

*

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

Which of the following statements is true about the “#include” directive in C++?

A

It is used to include the contents of one file into another during the compilation process.

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

Given the following, which statement is correct?

int x = 10;
int *ptr = &x;?

A

x stores a value, ptr stores a memory address.

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

What is the correct way to declare a pointer to an integer in C++?

17
Q

What is the purpose of the delete keyword in C++ in relation to pointers?

A

To deallocate memory previously allocated with new.

18
Q

Which can declare a C++ enumeration named “Colors” with values Red, Green, and Blue?

A

enum Colors { Red, Green, Blue };

19
Q

By default, what integer values are assigned to the enumerators in a C++ enumeration?

A

Values starting from 0 and incrementing

20
Q

Which of the following statements is true regarding the initialization of a struct in C++?

A

A struct can be initialized using curly braces {}