C++ Variables
Variable can be defined as a container to hold data. Variable names must start with a letter of the alphabet or an underscore. Variables are of different types, for example: Types of variables:
float and double are also types for variables with large and floating point values.
type identifier = initial_value;
Example :
Declaring Variables:
The syntax to declare a new variable in C++ is straightforward: we simply write the type followed by the variable name (i.e., its identifier).
Syntax:
Example:
Create a variable called Num1of type int and assign it the value 14:
Output :
Add Variables Together :
To add a variable to another variable, you can use the + operator:
Output:
float and double are also types for variables with large and floating point values