CPP Data Types Examples

C++ Tutorial

💻 CPP Data Types Examples with Output (Beginner → Exam → Interview)

Below are clear, practical examples of CPP Data Types Examples, each with code and output for easy understanding.


1️⃣ Integer Data Type (int) ⭐


 

Output

25

2️⃣ Floating Data Type (float) ⭐


 

Output

89.5

3️⃣ Double Data Type (double) ⭐


 

Output

3.14159

4️⃣ Character Data Type (char) ⭐


 

Output

A

5️⃣ Boolean Data Type (bool) ⭐


 

Output

1

📌 true → 1, false → 0


6️⃣ String Data Type (string) ⭐


 

Output

Sanjit

7️⃣ Multiple Data Types Together ⭐⭐


 

Output

20
5.8
A
Amit

8️⃣ Derived Data Type – Array ⭐⭐


 

Output

10 20 30

9️⃣ User-Defined Data Type – struct ⭐⭐


 

Output

1 85.5

🔟 Size of Data Types ⭐⭐


 

Sample Output

4
4
1

📌 Size may vary by compiler/system.


📌 Common Exam Questions

Q1. Which data type stores decimal values?
👉 float, double

Q2. Which data type stores true/false?
👉 bool

Q3. Which data type stores text?
👉 string


✅ Summary

int → whole numbers
float / double → decimals
char → single character
bool → true/false
string → text
✔ Arrays & structs → complex data

You may also like...