The variable in c language is the name of the store location. These locations are used to store the data. And we can change the data at that location multiple times. Different type of variable take different memory size in storage according to their data type
i.e int contains 2 bytes.
- The variable in the C programming language is also called a container to store the data.
- Different type of data types contain the different size of memory in storage
- The variable in c is also called the building block of c programming. Which is called an Identifier.
- A Variable is the actual location of memory where the data is stored
Type of Variables
- Local Variables
- Global Variables
Local Variables
- These variables having the local scope of access.
- Local variables are accessible only from the inside of the function or block in which it is declared.
- It has higher priority than Global variables
Global Variables
- Global variables are variables that have global scope
- Scope of Global variables is throughout the program [i.e. in all function including main()]
- The global variable can’t be accessible inside the function if you declared a local variable with a name inside the function because the global variable has a higher priority.
Variable name Rules in C programming language
- A variable can’t alphabets(a-z,A-Z), digits(0-9), and underscore(_).
- A variable name can’t start with a digit
- The variable name can be started from the alphabet and underscore.
- White space is not allowed in the variable name
- A variable name must not be any reserved word or keyword, e.g. int, float, etc.
Constant in C Programming
A constant is an identifier with an associated value which can’t be alternate by the program during execution
How to declare the constant in c programming language
float const pi = 3.14; int const a = 5; char const yes = 'y';