Variables
A variable is an identifier or a name which is used to refer a value. A variable is a name of the memory location where data is stored.
Each variable in C has a specific type, which determines the size of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
Rules for Constructing Variable Names
- A variable name is any combination of alphabets, digits or underscores
- The first character in the variable name must be an alphabet or underscore.
- Upper and lowercase letters are distinct because C is case-sensitive
- No whitespace is allowed within the variable name.
In C Language, the variable can be Declare or declaration with initialization. If you declare a variable, that means you are asking the compiler to reserve a piece of memory with that variable name. If you declare with initialize a variable, that means you are asking the compiler to reserve a piece of memory with that variable name and store the data at reserved memory.
Variable Declaration in C
Syntaxdatatype variable_name;example:
int id;
float bassal;
Variable Declaration with initialization
Syntaxdatatype variable_name = constant_value;example:
int id = 5;
float bassal = 18000;
This type declaration is done at the beginning of the program.