Variable naming convention.

Hello coders! Welcome back.
In the last blog, we have glanced about the variable.

Today will be looking into naming conventions of variables.

The variable name is composed of letters or a group of letters and digit.

There are certain rules to be followed otherwise the compiler reports an error.

RULES-

  1. Don't start a variable name with a digit. 
  2. Don't start a variable with an underscore. Even though it's valid but it's not recommended. The reason is that large variables are used for system use. 
  3. Variables are case sensitive. Usually, small letters are used for variable declarations and capital letters are used for global declaration. 
          case sensitive means upper case alphabets and lower case alphabets both are treated differently. For more clarity lets take an example. 











The compiler treats all the above variables names differently, this is referred to as case sensitive.

       4. The use of special characters is not allowed. Special characters such as @ # % ^ *. Anyhow you can use them in between the alphabets but not at the beginning and at the ending of a variable name.
      5. Blank or white space is not allowed. If you want to use a group of words we can use underscore in between two words. For example -









       6. Use of keywords such as while, if, for, return, etc are not allowed. If you even want to use them in your code then make all of the keywords in uppercase or either one alphabet in uppercase. As we know that it is case sensitive.

💡PRO TIP:- Never use too long variable names. Using those again in code makes it difficult. 

I hope so, you found it helpful. If and doubts drop a comment always ready to solve your doubt. 

Happy learning! 

Comments

Popular post