Skip to main content

storage classes in C - Computer science fundamentals tutorial

Storage class in C

Storage class defines the scope (visibility) and lifetime of variables and/or functions declared within a C program.  It stored in RAM or CPU register. There are Four storage class into which variables are declared & stored.
1.   Auto storage class.
2.   Static storage class.
3.   Extern storage class.
4.   Register storage class.


1.   Auto storage class: - Variable declared in this class is stored In RAM. This is the default storage class and the keyword ‘auto’ is used declare variables. Auto variables are active in a block in which they are declare. Auto storage class is commonly used in all C program without a keyword ‘auto’.
Example:- auto int a;
2.   Static storage class:- Variables declares in this class are also stored in the RAM. The keyword ‘static’ is used to declare these variables. Similar to auto variable, the static variable are also active in the block which they are declared and they retain the latest value.

Example: static int a=10;

3.   Extern storage class: - Global variable are decided using this class & they are stored in RAM. The key ‘extern’ is used to declare this variable. The global variables are also declared outside the main function. Extern class can be used consider a local variable in a block as a global variable.

Example: - extern int a;

4.   Register storage class: - Variables declare using this class is stored in the CPU memory register. The keyword register is used to declare these variables. Only a few variables which are frequently used in the program and declared using this class to improve the program executing speed. The behaviour of register variable is similar to that of auto variables except that their storage locations are different. In case of non availability of CPU memory register, these variables are stored in RAM as auto variables.

Example: - register int a;


Comments

Popular posts from this blog

Solve-write C program to find biggest number from three number by using nested if statement

          C program to find biggest number from three number                                                by using                                                                 nested if statement Problem Description This program takes the 3 numbers and finds the biggest among all. Problem Solution 1. Take the three numbers as input. 2. Check the first number if it greater than other two. 3. Repeat the step 2 for other two numbers. 4. Print the number which is greater among all and exit. Program codes:- here the program of finding biggest of three number run this in your Linux, DEV C++,turbo c++ #include<stdio.h> main() { int num1,num2,num3,big;   ...

Important MCQ of RDBMS( Relational database management system)-FCST

Important MCQ of RDBMS  1. A RDBMS consists a collection of ? a. Tables b. Fields c. Records d. Keys  ANS/- a. table 2. The term attribute refers to a ___________ of a table a. Record b. Tuple c. Column d. Key   ans/- c. Column 3. In relational model, the row of table is known to be ?  a. Relation b. Entity field c. Tuple d. Attribute  ans/- C. Tuple 4. . Address field of a person should not be part of primary key, since it is likely to ? a. Dependent b. Too long c. Changed d. Not changed  ans/- c. Changed 5. The relational model is concerned with ? a. Data structure and Data integrity b. Data Manipulation c. Both a and b d. None of these  ans/- c. Both a and b 6. Which is the false statement from the following ? a. A veiw is a named derived table b. A name relation is variable c. A veiw is a named reation and is virtual d. None of these  ans/- d. None of these 7. The union of primary key...

Short notes on database schema & database independence- computer science fundamentals tutorial

            Database Schema &  Data Independence PDF version of this post also available. to download the click the link given at the end of this post.           Database Schema : -  A database schema   is the skeleton structure that represents the logical view of the entire database. It defines how the data is organized and how relat ion among them are associated.  Database schema  formulates all the constrains that are to be applied on the data. A database schema defines its entities and the relationship among them. It contains descriptive details of the database which can be described by means of schema diagram. A database schema can be divided into two categories.   I.     Physical database schema : - this schema contain to the actual storage of data and its form of storage like files, indices etc. It defines how the data will be stored in a secondary storage. ...