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

Minterm and maxterm in Digital logic design - Computer Science fundamentals tutorial

Minterm and Maxterm First thing to know before we proceed   towards   what is ‘minterm’ and ‘maxterm’ we have to know the sum of product and product of sum. Sum of product: - The logical sum of two or more logical product term is called sum of products expression. It is basically an OR operation of AND operated variables such as Y = AB+BC+ABC Product of Sum: - The logical product of two or more logical sum term is called product of sums expressions. It is basically an AND operation of OR operated variables such as Y = (A+B).(B+C).(A+B+C) Minterm: - Product term containing all the k variables of the functions is either complimented or uncomplimented form is Minterm. Canonical form of sum of product: - It is defined as the logical sum of all the minterms derived from the rows of a truth table for which value of the function is 1. It is called a minterm canonical form. The canonical sum of product expression can be given in a compact form by lis...

Solve-write C program to find grade of student by using nested else-if statement

C program to find grade of student by using nested else-if statement Problem Description This program take input as your number then show your grade. Problem Solution 1. enter your marks as input. 2. then check your marks with 'If' block's condition. if it satisfied then show your grade as output. 3. if it not satisfied then it checks with all else-if block's condition repeatedly. 4. print the grade according to your given marks as input and exit. Program codes:-   #include<stdio.h> main() { int n; printf("\n enter the marks:"); scanf("%d",&n); if(n>89) printf("O"); else if(n>79) printf("E"); else if(n>69) printf("A"); else if(n>59) printf("B"); else if(n>49) printf("C"); else if(n>39) printf("D"); else printf("F"); } Program explanation:- 1. enter your marks. for example we take 70 . ...

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...