Primitive Data Types in C++
🟢 Beginner
📖 Primitive Types Table
| Type | Size (Bytes) | Description | Example |
|---|---|---|---|
int | 4 | Signed integers | 42 |
float | 4 | Single precision floating point | 3.14f |
double | 8 | Double precision floating point | 2.71828 |
char | 1 | Single ASCII character | 'A' |
bool | 1 | Boolean true/false | true |
💡 Code Example
#include <iostream>
int main() {
int age = 25;
double price = 19.99;
char grade = 'A';
bool passed = true;
std::cout << "Age: " << age << ", Price: $" << price << ", Grade: " << grade << ", Passed: " << std::boolalpha << passed << "\n";
return 0;
}
👀 Output
Age: 25, Price: $19.99, Grade: A, Passed: true