C++ Programming MCQ – Data Types

This section on C++ interview questions and answers focuses on “Data Types”. One shall practice these interview questions to improve their C++ programming skills needed for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C++ programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C++ interview questions come with the detailed explanation of the answers which helps in better understanding of C++ concepts.

Here is a listing of C++ interview questions on “Data Types” along with answers, explanations and/or solutions:

1. 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
View Answer

Answer: d
Explanation: Compiler wants to make CPU as more efficient in accessing the next value.

2. Pick the odd one out.
a) array type
b) character type
c) boolean type
d) integer type
View Answer

Answer: a
Explanation: Array type is not the basic type and it is constructed using the basic type.

3. Which data type is used to represent the absence of parameters?
a) int
b) short
c) void
d) float
View Answer

Answer: c
Explanation: Because void specifies an empty set of values/parameters.
advertisement
advertisement

4. What does ‘\a’ escape code represent?
a) alert
b) backslash
c) tab
d) form feed
View Answer

Answer: a
Explanation: Because \a is used to produce a beep sound.

5. Which type is best suited to represent the logical values?
a) integer
b) boolean
c) character
d) float
View Answer

Answer: b
Explanation: Logical values can be either true or false, so the boolean type is suited for it.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Identify the user-defined types from the following?
a) enumeration
b) classes
c) both enumeration and classes
d) int
View Answer

Answer: c
Explanation: They must be defined by the users before use, unlike the other types which are readily available.

7. Which of the following statements are true?

advertisement
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
View Answer

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

8. The value 132.54 can be represented using which data type?
a) double
b) void
c) int
d) bool
View Answer

Answer: a
Explanation: The given value is with decimal points, so float or double can be used.

9. When a language has the capability to produce new data type mean, it can be called as
a) overloaded
b) extensible
c) encapsulated
d) reprehensible
View Answer

Answer: b
Explanation: Extensible is used to add new features to C++.

10. Pick the odd one out.
a) integer, character, boolean, floating
b) enumeration, classes
c) integer, enum, void
d) arrays, pointer, classes
View Answer

Answer: c
Explanation: integer, character, boolean & floating consists of all fundamental types, enumeration & classes consists of user-defined types and arrays, pointer & classes consists of derived types but integer, enum & void is a mixture.

Sanfoundry Global Education & Learning Series – C++ Programming Language.

To practice all areas of C++ language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.