Writing computer programs means storing lots of Data and Information. This directly stored in to the computer volatile memory (RAM- Random Access Memory). Therefore, when you want to store it you also have to keep a track with each. While storing these we have to name the memory location where we store the Data or Information, this is known as Variable or Identifier.
Variable is the name of the memory location given by the user to store data or information. Therefore, a variable is a facility for storing data and user can choose the name as they want but have to maintain few rules. Most of the programming languages, the rules are same.
Rules of naming variable:
- All variable should start with an alphabet.
- A numeric digit allowed.
- Space or special characters (Symbols) not allowed but note for few exception bellows.
- No keyword can be use as identifiers.
In Java, C, C++ you can use a underscore (e.g. Emp_name). In Basic, (I cannot forget you) you can use a dot(.). In addition, while storing Alphanumeric values (Alphabets, numbers and symbols) the variable should ends with a dollar ($) sign. The Variable store the alphanumeric data are also known as String
Variable. Example of Variable – Java, c, c++, c# - A, NO, NUM, I, I123.
Basic - A, NO, NUM For numeric variable and A$, B$, A123$ IS FOR String variable.
Keyword – Reserved words that convey meaning to the computer. Used to write programming syntax. A programming syntax or statement should have at least one keyword. (E.g. Input, printf(), cout<<, int, class)
Some OOPs (Object Oriented Programming) Variable or Identifier name is case sensitive. That means if you give a variable name Num, num, Num, NUM, all will work as different name.
So once again its time to say Adio, milte hai next week with concept of Data Type, but this one for you
[Variables are free of charge but do not misuse it, do not declare more than you need, its occupy memory space and most unprofessional thing to do.]
No comments:
Post a Comment