Variables, and keyword in c++ language
C++ Variable:
A variable is a name of the memory location. It is used to store data. Its value can be changed and it can be reused many times.
It is a way to represent memory location through symbol so that it can be easily identified.
syntax to declare a variable:
type variable_list;
Rules for defining variables
- A variable can have alphabets, digits, and underscore.
- A variable name can start with the alphabet and underscore only. It can't start with the digit.
- No whitespace is allowed within the variable name.
- A variable name must not be any reserved word or keyword e.g. char, float etc
Types
|
Data Types
|
Basic
Data Type
|
int,
char, float, double, etc
|
Derived
Data Type
|
array,
pointer, etc
|
Enumeration
Data Type
|
enum
|
User
Defined Data Type
|
structure
|
Basic Data Types
Data Types
|
Memory Size
|
Range
|
char
|
1 byte
|
-128 to
127
|
signed
char
|
1 byte
|
-128 to
127
|
unsigned
char
|
1 byte
|
0 to
127
|
short
|
2 byte
|
-32,768
to 32,767
|
signed
short
|
2 byte
|
-32,768
to 32,767
|
unsigned
short
|
2 byte
|
0 to
32,767
|
int
|
2 byte
|
-32,768
to 32,767
|
signed
int
|
2 byte
|
-32,768
to 32,767
|
unsigned
int
|
2 byte
|
0 to
32,767
|
short
int
|
2 byte
|
-32,768
to 32,767
|
signed
short int
|
2 byte
|
-32,768
to 32,767
|
unsigned
short int
|
2 byte
|
0 to
32,767
|
long
int
|
4 byte
|
|
signed
long int
|
4 byte
|
|
unsigned
long int
|
4 byte
|
|
float
|
4 byte
|
|
double
|
8 byte
|
|
long
double
|
10 byte
|
|