C variable attributes



Fundamental Attributes of C Variable :

  1. Name of a Variable
  2. Value Inside Variable
  3. Address of Variable
  4. Size of a Variable
  5. Type of a Variable

1.Name of Variable

  • We can Give proper name to any Variable which is human readable.
  • Compiler won’t understand this name , This is only for human understanding.
  • Variable name is only the name given to the “Memory address”.
  • Variable name maps into “Address inside” and then by considering mapped address compiler processes data.
  • We have declared variable means “We have created one empty container which will hold data“.

2.Value inside Variable

  • Depending on the type of Variable we can store any value of appropriate data type inside Variable.
  • Suppose we have “Integer Variable” then Value inside variable will be of type “Integer“.
  • Simple Variable can only hold one value at a time.

3.Address of Variable

  • Variable can hold data ,it means there should be a container.
  • So container must have Starting Address.
  • Address of variable = Starting Address of Memory where Memory is allocated to Variable.

4.Type of Variable

  • While declaring a variable we have to specify type of variable.
  • Type of variable tells compiler that - “Allocate memory for data of Specified type“.
  • If we declare variable of type Integer then compiler will allocate memory container of size 2 bytes and container will be able to store integer data only.

5.Size of Variable

  • We can use sizeof operator to calculate size of any data type.

Variable attributes

Variable attributes

Variable Name ivar
Variable Type Integer
Variable Address 2000
Variable Size 2 Bytes
Variable Value 34