All C++ variables must be identified with unique names.
These unique names are called identifiers.
Identifiers
can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
#include <iostream>
using namespace std;
int main()
{
int age = 24;
string name = "I am learning C# at the moment";
string country = "Uzbekistan";
cout << name << endl;
cout << country;
return 0;
}
The general rules for naming variables are:
Names can contain letters, digits and underscores
Names must begin with a letter or an underscore (_)
Names are case sensitive (
myVar
andmyvar
are different variables)Names cannot contain whitespaces or special characters like !, #, %, etc.
Reserved words (like C++ keywords, such as
int
) cannot be used as names
Top comments (0)