C++ Basics
Variables and Data Types
In C++ you must declare the type of every variable.
int age = 21;
double price = 99.5;
char grade = 'A';
bool passed = true;
string name = "Ali"; // needs #include <string>
const double PI = 3.14159; // can't change| Type | Stores | Example |
|---|---|---|
int | Whole numbers | 42 |
long long | Very large whole numbers | 9000000000 |
double | Decimals | 3.14 |
char | One character, single quotes | 'A' |
bool | true / false | true |
string | Text, double quotes | "Hello" |