Difficulty: Beginner
Programming Language: C++

In computer programming we use variables to perform calculations and output additional information to the user. In this article we will illustrate how to create a variable and also show what variable types and type modifiers are available for C++.

Below is our Hello World example, this time with a demonstration of how to create a variable and output it's value to the terminal window.

You can see from the example above that to declare a variable, we state the variable type and then give the variable an identifier. An identifier is a unique name that will be used to reference this variable and has a few strict rules about how it must be named.

An identifier must start with an alphabetical character or an underscore (A-Z, a-z, _). The rest of the name may be made up of any alphanumeric character and the underscore (A-Z, a-z, 0-9, _).

There are also some common styling conventions followed in C++. One of the most common styling conventions is that all typenames, functions names and variable names are written in camel case. Camel case is a naming convention where the first word in the identifier or typename is all lower case, then every following word starts with an uppercase character and the rest of the word is lower case. Here is an example of the camelCase naming convention int exampleVariableOfTypeInt = 5.