Skip to content
Question of 97

Q.Write the names of any four fundamental data types of C++.

CBSECBSE Class XII Board 2019Subjective· 2mImportance★★★★★est
0% · 0/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The four fundamental data types in C++ are int, char, float, and bool. These are the building blocks for representing integer, character, floating-point, and Boolean (true/false) values respectively.

The Concept: What Makes a Data Type "Fundamental"?

In C++, a fundamental data type is one that is built directly into the language — not composed from other types. Think of them as the atoms of the type system. Every other type (arrays, classes, pointers) is built on top of these. The C++ standard guarantees that these types exist on every compliant compiler, though their exact sizes can vary by platform.

The four you'll encounter first — and the ones most exam questions expect — are:

  1. int — for whole numbers (integers).
  2. char — for a single character (like 'A' or '9').
  3. float — for single-precision decimal numbers.
  4. bool — for logical values (true or false).

Let's walk through each one.


1. int — Integer Type

int stores whole numbers (no fractional part). On most modern systems, it occupies 4 bytes (32 bits), giving a range of roughly −231-2^{31} to 231−12^{31}-1 (about −2.1×109-2.1 \times 10^9 to 2.1×1092.1 \times 10^9).

int age = 25;
int temperature = -10;
Watch out

A common mistake is to assume int can hold any whole number. If you try to store a value larger than about 2.1 billion, you get integer overflow — the result wraps around, often giving a negative number. For larger integers, use long long.


2. char — Character Type

char stores a single character, but under the hood it's really a small integer (usually 1 byte, 8 bits). Each character is mapped to a numeric code (ASCII or extended ASCII).

char grade = 'A';   // stores the integer 65
char digit = '7';   // stores the integer 55

You can even do arithmetic on char values: 'A' + 1 gives 'B' (since 65 + 1 = 66).

Tip

Because char is technically an integer type, you can use it to store small numbers (0 to 255) if memory is tight. But for clarity, use int unless you specifically need a character.


3. float — Floating-Point Type

float stores real numbers with a decimal point, using single precision (usually 4 bytes). It can represent values like 3.143.14 or −0.001-0.001, but with limited precision — about 6–7 significant decimal digits.

float pi = 3.14159f;   // the 'f' suffix tells C++ it's a float, not a double
float speed = 299.792f;
Watch out

Never compare two float values directly with ==. Rounding errors mean that 0.1 + 0.2 might not equal 0.3 exactly. Use a small tolerance instead: if (abs(a - b) < 1e-6).


4. bool — Boolean Type …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.