Variables in C Programming

Variables in C Language
Variables in C Language

Variable is a location in memory where worth is often stored to be used by a program. Variables must be declared before they will give value. When declaring a variable, its name and data type should be specified. Variables have a name, type, and value.
The declaration allocates the storage location of the acceptable size and associates the name and data type with the correct location.

Variable Declaration in C

Format of a variable -
              <Data type><Name of the variable>

Example:



Variable Names in C

 C variable naming rules

  • A variable name can be a series of characters consisting of letters, digits, and underscores[ _ ]. 
  • The variable name does not begin with a digit.
  • A variable name may not contains embedded blank spaces.
  • A variable name may not be a reserved word. [ int, return, char, while, if ]
  • C language is a case-sensitive language. It's meaning is uppercase, and lowercase letters are different in C language.   [ name, Name, and NAME are three different variable names in c ]
valid variables and invalid variables in C programming
valid variables and invalid variables in C programming