✔ C-LANGUAGE CHAPTERS:-
1. C-Introduction
2. C-Constants
3. C-Basic Programs
4. C-Instructors
5. C-Operators
6. C-If Else Statement
7. C-Loop Contructs
8. C-Nesting Of Loops
9. C-Programming Examples
10. C-Functions
11. C-Functions Naming Convention
12. C-Pointers
13. C-Arrays
14. C-Arrays & Functions
15. C-Strings
16. C-Structures
17. C-Union
18. C-Storage Classes
19. C-PreProcessor
20. C-Header Files
21. C-R/W one Line
22. C-Accessing Random File
23. C-Important Point
24. C-Interview Questions
1. C-Introduction
2. C-Constants
3. C-Basic Programs
4. C-Instructors
5. C-Operators
6. C-If Else Statement
7. C-Loop Contructs
8. C-Nesting Of Loops
9. C-Programming Examples
10. C-Functions
11. C-Functions Naming Convention
12. C-Pointers
13. C-Arrays
14. C-Arrays & Functions
15. C-Strings
16. C-Structures
17. C-Union
18. C-Storage Classes
19. C-PreProcessor
20. C-Header Files
21. C-R/W one Line
22. C-Accessing Random File
23. C-Important Point
24. C-Interview Questions
Storage classes refer to ‘availability’ of a variable. ‘Availability’ can be defined as:
- Life time of variable
- Scope of variable
- Visibility of variable
Scope of variable, it describes those areas of program, where a variable can be accessed. Scope also affects a variable`s lifetime.
Life time of variable, it defines how long the variable persists in memory, or we can say that when space is allocated or de-allocated to variable.
Types of Scopes: -
Generally there are 4 types of scope where a variable can be visible to programmer.- Program scope
- File scope
- Function scope
- Block scope
Program scope: - This scope defines that a variable is available in entire program. We can say that a variable is active among different source files.
File scope: - It signifies that variable is available from the point where it is declared i.e. after the main( ) function till the end of file.
Function scope: - It signifies that a variable is active with in a function block only.
Block scope: - it signifies that the variable is available from its declaration point till the end of block.
Local and Global Variable: - The variables are generally classified into two:
- Local variable
- Global variable
Local variable: - ‘local’ is the scope of variable. Local variables are private. They are private to the block in which they are declared.
For Eg: - function addition(int a, int b)
{
int sum = 0; /* Local variable */
sum = a + b;
return sum;
}
The variable sum is only available within the function. The same variable name can take for other variable within a program but in same block. Like in other function or in main( ). The variables are by default initialized with garbage value in c programming.
Global variable: - Their scope is within the program these variables are defined outside the main( ).
Global variable: - Their scope is within the program these variables are defined outside the main( ).
The priority of Global variables are high.
For Eg: - int a, b; /* Global Variable */
void main( )
{
a = 20; /* Global variable accessible */
sum( );
}
sum( )
{
int ans;
ans = a + b;
}
There are 4 types of storage class specifiers :
- Auto
- Static
- Register
- Extern
- auto: -
Life time: Only to the block in which they are declared.
Visibility: We can read/write only in that block in which they are declared. Like in function or in main( ).
Location: They occupy the space in primary memory i.e. RAM.
Initialization: Since they are local variables so they by default initialized with garbage value.
‘auto’ keyword is applied with the variable name.
- static: -
Life time: Remains in the memory till the End of the program.
Visibility: We can read/write only in that block in which they are declared.
Location: They occupy the space in primary memory i.e. RAM.
Initialization: They are initialized with Zero.
‘static’ keyword is applied with the variable name.
- register: -
Life time: Only to the block in which they are declared.
Visibility: We can read/write only in that block in which they are declared.
Location: They occupy the space in Registers of CPU.
Initialization: They are by default initialized with garbage value.
‘register’ keyword is applied with the variable name.
- extern: -
Life time: Remains in the memory till the End of the program.
Visibility: We can read/write anywhere in entire program.
Location: They occupy the space in primary memory i.e. RAM.
Initialization: They are by default initialized with Zero.
‘extern’ keyword is applied with the variable name.