Question:

Which of the following data types is supported in C++ but not in C ?

Show Hint

The introduction of the native `bool` type is a key difference between C and C++. It enhances type safety and code readability.
  • int
  • bool
  • double
  • float
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Step 1: Compare the data types of C and C++.
Both C and C++ support fundamental data types like \( \texttt{int} \), \( \texttt{float} \), and \( \texttt{double} \).

Step 2: Identify the difference.
The \( \texttt{bool} \) data type, which holds the values \( \texttt{true} \) or \( \texttt{false} \), was formally introduced in C++. The original C language (ANSI C/C90) did not have a built-in boolean type and simulated it using integers (0 for false, non-zero for true). Later, C99 added a boolean type via the \( \langle \texttt{stdbool.h} \rangle \) header. In C++, \( \texttt{bool} \) is a native, first-class type.

Was this answer helpful?
0
0