C++ Data Types
Basic types: int, long, short, float, double, char, bool and std::string. auto lets the compiler deduce the type, and sizeof shows byte sizes.
Example
int i = 42; double d = 3.5; char c = 'A'; bool ok = true; string s = "C++";
auto n = 7L;
cout << i << " " << d << " " << c << " " << ok << " " << s << "\n";
cout << sizeof(int) << " " << sizeof(double) << " " << sizeof(n) << "\n";Result
42 3.5 A 1 C++ 4 8 8
Exercise
Deduce the type.
x = 5;Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.