C++ Constants & Data Types | Set 1
1. The constants are also called as
a) Const
b) preprocessor
c) literals
d) none of these
Answer: C
Explanation: No explanation is given for this question.
2. What are the parts of the literal constants?
a) integer numerals
b) floating-point numerals
c) strings and boolean values
d) all of the mentioned
Answer: D
Explanation: Because these are the types used to declare variables and so these can be declared as constants.
3. What is the size of wchar_t in C++?
a) 2
b) 4
c) 2 or 4
d) Based on the number of bits in the system
Answer: D
Explanation: Compiler wants to make CPU as more efficient in accessing the next value.
4. Pick the odd one out.
a) array type
b) character type
c) boolean type
d) integer type
Answer: A
Explanation: Array type is not the basic type and it is constructed using the basic type.
5. Which data type is used to represent the absence of parameters?
a) int
b) short
c) void
d) float
Answer: C
Explanation: Because void specifies an empty set of values/parameters.
6. What does ‘\a’ escape code represent?
a) alert
b) backslash
c) tab
d) form feed
Answer: A
Explanation: Because \a is used to produce a beep sound.
7. How the constants are declared?
a) const keyword
b) #define preprocessor
c) both a and b
d) None of these
Answer: C
Explanation: The const will declare with a specific type values and #define is used to declare user definied constants.
8. Which type is best suited to represent the logical values?
a) integer
b) boolean
c) character
d) float
Answer: B
Explanation: Logical values can be either true or false, so the boolean type is suited for it.
9. Identify the user-defined types from the following?
a) enumeration
b) classes
c) both enumeration and classes
d) int
Answer: C
Explanation: They must be defined by the users before use, unlike the other types which are readily available.
10. Which of the following statements are true?
int f (float)
a) f is a function taking an argument of type int and returning a floating point number
b) f is a function taking an argument of type float and returning an integer
c) f is a function of type float
d) f is a function of type int
Answer: B
Explanation: The argument that is passed to a function f is of float type and the function finally returns a value that id is of integer type.