特权:标识符、变量
身份标识
标识符用于命名变量、函数和数组。它是字符串以字母表或下划线 ( _ ) 开头的字母数字字符,用于变量、函数、数组、结构、联合等。它也被称为用户定义的词。标识符名称的拼写和大小写必须与任何关键字不同。我们不能使用关键字作为标识符;它们保留用于特殊用途。一旦声明了一个标识符,我们就可以在程序中的任何地方使用该标识符来引用相关联的值。
变量
变量是指向内存位置的名称。它是程序中存储的基本单位。在程序执行期间可以更改变量的值。所有的操作都是在影响内存位置的变量上完成的。在 C 中,所有变量都必须在使用前声明,而在 C++ 中,我们可以在方便的时候在程序中的任何地方声明。
标识符和变量之间的区别
Identifiers | Variables |
---|---|
It is a unique name which is given to an entity to distinctly identify it meanwhile the execution of the source-code | A Variable is a name that is assigned to a memory location, which is used to contain the corresponding value in it. Variables are only the sort of identifiers. |
It strictly prohibited to have the same of two or more identifiers. It Ex’s: are Structure name, Function name, Class, Enumerator name, Union, etc. | It wouldn’t be an exaggeration to say that all variables are identifiers whereas vice-versa isn’t true. The values can be Real, Char, String, Int, Float, Double, Unsigned, etc. |
An identifier name shouldn’t resemble with the keywords because keywords are predefined. Double, Continue, float, else, etc can’t be used as identifiers in a program. | The value that is stored in memory block can be modified meanwhile the program executed. Similarly, as identifiers, two or more variables also can’t have the same name in a program. |
Ex: enum geeks_artiles_in { Jan=1, Feb, Mar, Apr, May, June, July } Ex: int geeks_f_geeks ( int gfg_id ) { /* …. code …… */ } |
Ex: short int geeks_id{} , int a{} , long float b{ } , unsigned int c{ } , char ch , etc |