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-
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!
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-
- Don't start a variable name with a digit.
- 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.
- Variables are case sensitive. Usually, small letters are used for variable declarations and capital letters are used for global declaration.
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
Post a Comment