c plus Flashcards

(61 cards)

1
Q

What are tokens in C++?

A

Tokens are the smallest individual units in a program.

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

What are the types of tokens available in C++?

A
  • Keywords
  • Identifiers
  • Constants
  • Strings
  • Operators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define keywords in C++.

A

Keywords are reserved words with predefined meanings that cannot be used for other purposes.

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

What does the ‘auto’ keyword do in C++?

A

Automatically identifies the data type of a variable based on its initializer.

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

What is the purpose of the ‘default’ keyword in C++?

A

Specifies default behavior related to constructors, function arguments, or switch cases.

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

What does the ‘break’ keyword accomplish in C++?

A

Exits a loop or switch case statement.

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

What is the function of the ‘case’ keyword in C++?

A

Marks a particular case in a switch statement.

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

What does the ‘char’ keyword represent in C++?

A

Represents a character type (1 byte).

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

What does the ‘const’ keyword indicate in C++?

A

Defines a variable that cannot be changed after initialization.

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

What is the role of the ‘continue’ keyword in C++?

A

Skips the current iteration of a loop and proceeds to the next one.

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

What does the ‘double’ keyword represent in C++?

A

Represents a double-precision floating-point number.

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

What is the purpose of the ‘else’ keyword in C++?

A

Specifies an alternative to the if statement.

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

What does the ‘enum’ keyword do in C++?

A

Defines an enumerated data type.

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

What does the ‘float’ keyword represent in C++?

A

Represents a single-precision floating-point number.

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

What is the function of the ‘for’ keyword in C++?

A

Creates a loop that iterates over a defined range.

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

What does the ‘if’ keyword create in C++?

A

Creates a conditional statement that evaluates whether a condition is true or false.

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

What does the ‘int’ keyword represent in C++?

A

Represents an integer type, typically 2 or 4 bytes.

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

What does the ‘long’ keyword represent in C++?

A

Represents a long integer type, typically 4 or 8 bytes.

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

What is the role of the ‘namespace’ keyword in C++?

A

Creates a namespace that can contain variables and functions.

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

What does the ‘new’ keyword do in C++?

A

Dynamically allocates memory during program execution.

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

What is the purpose of the ‘return’ keyword in C++?

A

Exits a function and optionally returns a value.

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

What does the ‘short’ keyword represent in C++?

A

Represents a short integer type, typically 2 bytes.

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

What does the ‘signed’ keyword specify in C++?

A

Indicates that a variable can hold negative and positive values.

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

What does the ‘static’ keyword indicate in C++?

A

Specifies that a variable or function belongs to the class and is not an instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the 'struct' keyword define in C++?
Defines a composite data type, similar to a class.
26
What is the function of the 'switch' keyword in C++?
Creates a switch statement that evaluates an expression against a range of possible values.
27
What does the 'typedef' keyword do in C++?
Creates aliases for data types.
28
What does the 'unsigned' keyword specify in C++?
Indicates that a variable can hold only positive values.
29
What does the 'sizeof' keyword return in C++?
Returns the size in bytes of a data type or variable.
30
What are identifiers in C++?
Unique names given to variables, classes, functions, or other entities by the programmer.
31
What are the rules for naming an identifier in C++?
* Can consist of letters, digits, and underscores * Must begin with a letter or underscore * Cannot use reserved keywords * Must be unique in its namespace * Case-sensitive
32
List the built-in types in C++.
* int * char * float * double * long double * void
33
What are the user-defined types in C++?
* struct * class * union * enum
34
What are derived data types in C++?
* Arrays * Pointers * References * Functions
35
What is the purpose of the 'void' type in C++?
* Specifies the return type of a function when it is not returning any value * Indicates an empty argument list to a function.
36
What does the 'signed' modifier indicate?
The data type can hold both positive and negative values.
37
What does the 'unsigned' modifier indicate?
The data type can only hold non-negative values.
38
What does the 'short' modifier do?
Reduces the size of the data type (usually 2 bytes).
39
What does the 'long' modifier do?
Increases the size of the data type (varies by implementation).
40
What does the signed modifier indicate in C++ data types?
The data type can hold both positive and negative values.
41
What does the unsigned modifier indicate in C++ data types?
The data type can only hold non-negative values.
42
What is the effect of the short modifier on data types?
Reduces the size of the data type (usually 2 bytes).
43
What does the long modifier do to data types in C++?
Increases the size of the data type (varies by implementation).
44
How many bytes does a char data type use in C++?
1 byte.
45
What is the range of an unsigned char in C++?
0 to 255.
46
What is the range of a signed char in C++?
-128 to 127.
47
How many bytes does an int data type use in C++?
2 bytes.
48
What is the range of an unsigned int in C++?
0 to 65535.
49
What is the range of a signed int in C++?
-32768 to 32767.
50
How many bytes does a long int data type use in C++?
4 bytes.
51
What is the range of an unsigned long int in C++?
0 to 4294967295.
52
How many bytes does a float data type use in C++?
4 bytes.
53
What is the range of a double data type in C++?
1.7E-308 to 1.7E+308.
54
How many bytes does a long double data type use in C++?
10 bytes.
55
What is a symbolic constant in C++?
A way to give a meaningful name to a constant value.
56
What keyword is used to define a constant variable in C++?
const.
57
What is an advantage of using the const keyword?
Directly associates the constant with a variable type.
58
What does the constexpr keyword indicate?
The value of the constant is evaluated at compile time.
59
What is an advantage of using constexpr over const?
Ensures that the value is constant and available at compile time.
60
Fill in the blank: Symbolic constants are typically used to represent values that do not change throughout the execution of a program, such as _______.
[mathematical constants, configuration values, fixed parameters]
61