Variabels in C

  •  A variable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times.
  • It is a way to represent memory location through symbol so that it can be easily identified.
  • To manipulate memory address easily, we can attach a variable name to the memory address.
  • So, it will be very easier to manipulate the memory address using a variable name rather than hexadecimal values.
  • Datatype variable_name;  

Rules for Defining a Variable

1.  variable can have alphabets, digits, and underscore.
  • valid: abc, ab1, _abc;

2. A variable name can start with the alphabet, and underscore only. It can't start with a digit.
  • valid: var, _value, name;
  • Invalid: 1var, 23cr;

3. Variables are also case sensitive. 
  • Age and age is different variables.

4. No whitespace is allowed within the variable name.
  • valid: abc, variable_name;
  • Invalid: variable name, hel lo;

5.A variable name must not be any reserved word or keyword, e.g. int, float, main


0 Comments