🧩 C++ Data Types

🧱 What Are Data Types?
Data types tell the compiler what kind of data a variable will hold. Using the right type ensures memory efficiency and accuracy.
🔠Built-in Data Types
Type | Meaning | Example |
int | Integer values | int age = 21; |
float | Decimal numbers | float temp = 98.6; |
double | Double-precision float | double pi = 3.14159; |
char | Single character | char grade = 'A'; |
bool | True/False | bool passed = true; |
string | Text (needs <string> ) | string name = "Alex"; |
💡 Tips
Use
float
ordouble
for decimal calculations.Prefer
string
overchar[]
for text manipulation.Use
const
for values that shouldn’t change.
💼 Task for You
🔧 Task:
Declare one variable of each type and print their values in a formatted sentence.
🎯 What’s Next?
With variables and data types covered, you're ready to manipulate them. Let’s jump into operators — the tools to perform calculations and logic in C++.
📚 Follow the Series: C++ Zero to Hero
Subscribe to my newsletter
Read articles from Soumik Dastidar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Soumik Dastidar
Soumik Dastidar
I'm Soumik—a passionate problem solver, aspiring software developer, and lifelong learner. Currently building a C++ Complete Series to help beginners master programming from scratch. I love breaking down complex concepts, automating real-world tasks, and sharing what I learn. Let's grow together, one line of code at a time.