DEV Community

Kerimova_Manzura
Kerimova_Manzura

Posted on

C++ Identifiers

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;
}
Enter fullscreen mode Exit fullscreen mode

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 and myvar 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)