Ques:- What is storage classes?
Asked In :-
Daimler India Commercial Vehicles, Atigo Electronics India, FANUC, Vector India, Mobiveil, Mantra Softech, NAVYA, Skyworks Solutions, SignOff Semiconductors, Team Robocon IITR,
Right Answer:
Storage classes in C define the scope, visibility, and lifetime of variables. They determine where a variable is stored, how long it lasts, and how it can be accessed. The main storage classes are:
1. **auto**: Default for local variables, limited to the block in which they are defined.
2. **register**: Suggests that the variable be stored in a CPU register for faster access.
3. **static**: Preserves the variable's value between function calls and limits its scope to the file or function.
4. **extern**: Allows a variable to be accessible across multiple files, indicating that it is defined elsewhere.
Storage classes in C define the scope, visibility, and lifetime of variables. They determine where a variable is stored, how long it lasts, and how it can be accessed. The main storage classes are:
1. **auto**: Default for local variables, limited to the block in which they are defined.
2. **register**: Suggests that the variable be stored in a CPU register for faster access.
3. **static**: Preserves the variable's value between function calls and limits its scope to the file or function.
4. **extern**: Allows a variable to be accessible across multiple files, indicating that it is defined elsewhere.
Comments
Storage classes in C allocate the storage area of a variable that will be retained in the memory. They are stored in the RAM of a system. Apart from the storage space, they determine the scope of a variable. Variables in the C program are stored in a physical location in the random memory, which is mainly the device’s memory and CPU registers.
auto,
extern
static
register