capypad
0 day streak
cpp / beginner
Snippet

Variables and Data Types

C++ is a strongly typed language, meaning you must declare the type of data a variable will hold.

snippet.cpp
cpp
1
2
3
4
int age = 25;
double price = 19.99;
char grade = 'A';
bool isReady = true;
Breakdown
1
int age = 25;
Declares an integer variable named age.
2
double price = 19.99;
Declares a floating-point number for decimal precision.
3
bool isReady = true;
Declares a boolean that can be either true or false.