Perquisites :标识符,变量
身份标识
标识符用于变量,函数和数组的命名。它是字符串字母数字字符,以字母或下划线( _ )开头,用于变量,函数,数组,结构,联合等。也称为用户定义的单词。标识符名称的拼写和大小写必须与任何关键字不同。我们不能将关键字用作标识符;它们保留作特殊用途。声明了标识符后,我们可以在程序中的任何位置使用该标识符来引用关联的值。
变数
变量是指向存储位置的名称。它是程序中存储的基本单位。变量的值可以在程序执行期间更改。所有的操作都是在变量影响内存位置的情况下完成的。在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 |