Loading proofofbrain-blog...

Variable and Identifier

Hello
First of all, I want to thank @acidyo, @cadawg, @deathwing & @rishi556,@ocdb, @usainvote, @newsflash, @ocd, @joshman and other friends for their support. Today I want to talk about a concept called variable and identifier and its types in programming languages.


image.png

source

We're dealing with two memories. One is RAM and the other is hard drive. The difference between the two, and what is important to us, is that what is stored in RAM is lost after the computer is reset or turned off, but what you save on the hard drive remains.
In programming, if you save data in a file, this data remains, but by saving in RAM, the data can be lost.

The similarity between the two, which is important to us, is that the data, whether stored on the hard drive or in RAM, can be edited and replaced with new data. As soon as this change, the previous data will be lost.

understanding variables

The address of a place in memory that we give a name to and from that moment on, we can access the contents of that place with the same name and manipulate its data.

To understand this, I will give an example. Look at the picture below:

image.png
source

We have different boxes, each with a different address. We assign three names to the three boxes and then issue the following three commands:

  1. Put the content of height in age: The result of this command is as follows

images.png

  1. Put the content of weight in height: The result is as follows

2.png

  1. Put the content of age in weight: Listen to the result

3.png

You can see the sum of all the above three commands in the last figure.

The concept of variable is the same in all languages ​​and all you have to do is understand this concept and then know how to define a variable in that particular language - whether Python, C, etc.

Identifier concept


We said you have to specify a name for the variable. The name we specify for the variable is called the identifier.

Whatever language you work with, you have three concepts:

  1. Keywords: Reserved words that perform a specific action. These words belong to that language and have a special meaning for the compiler.
  2. Standard IDs: Words that, although not reserved, still perform a specific function. For example, the name of the definition functions within the language
  3. Non-standard identifiers: All names you define, such as variable names

The law of determining the identifier


Each language has a rule for defining an ID name. It's usually as follows

  1. The name you choose should not be a keyword or preferably a standard identifier. Of course, some languages ​​allow the definition of standard identifiers, but it is better to follow a general rule
  2. Specific length: Each language has a length range for the number of characters, for example in c, the length of your ID can be up to 63 characters.
  3. Sensitivity: Some languages ​​are case-sensitive, such as C, and others, such as Pascal, don't distinguish between uppercase and lowercase letters. My advice to you is to think, it's case-sensitive.
  4. In determining the ID name, you can follow the following three rules, which are common:
    a. Start with a letter [a-z A-Z] or _.
    b. The name can include numbers [0-9], letters [a-z A-Z] and _
    c. Do not use any other symbols except _.
    d .There should be no space in the name.

thanks to:
@ocdb @usainvote @newsflash @ocd @joshman @meritocracy @postpromoter @pishio @howo @belemo @takowi @steempress @bdmillergallery @roelandp @kevinwong @ocd-witness @eonwarped @pladozero @jlsplatts @walterjay @devann @dcrops @tipy @kephler @actioncats @quochuy @smartvote @dora381 @babeltrips @sunnyvo
H2
H3
H4
3 columns
2 columns
1 column
5 Comments