Skip to content
techsnow

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
TypeStoresExample
intWhole numbers42
long longVery large whole numbers9000000000
doubleDecimals3.14
charOne character, single quotes'A'
booltrue / falsetrue
stringText, double quotes"Hello"