What are Storage Classes in C ?
Answers were Sorted based on User's Feedback
Answer / nagalakshmanarao
storage classes in c defines the scope and lifetime of variables.the storage classes are important only in multifunction and multiple file programms.
storage classes are 4 types:they are 1:auto
2:static
3:extern
4:register
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mustaffa hasan
Auto,Static,Extern,Register.Auto are Local variables known
only to the function in which it is declared.Default is
auto.Static are Local variable which exits and retains its
value even after the control is transferred to the calling
function.Global are Global variables known to all functions
in the file.Register are Local variable which is stored in
register.
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / sujitpatel
there are 4 types of classes
1 extern
2 static
3 register
4 auto
auto is default storage class which is used as for the
default value . if something s written int a ; then its
default storage is called auto . whereas the scope of the
stATIC and register is for only a file .there is only a
difference that register is used for cpu and static is used
for main memory . the scope of the extern is global it is
used for the whole program .
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / vijay r15
storage class is an
attribute that changes
the behaviour of a
variable
There r 4types of
storage classes.They
are
auto
static
extern
register
auto- auto is the
default var type.
ex int x=1 and auto
int x=1 both r same
static- static
variable is a
variable,with in the
scope when it reaches
the initialization it
blindly igores and
hold the updated value
register-reg var tells
the compiler that the
variable will be
heavily used.It is
stored in cpu register
extern- extern var
tells that they have
allocated space in
some other program.
But just using here.
We cant initialize
using extern
with thanks and
regards,
vijay r15,
raj.Vijay55@gmail.Com
Is This Answer Correct ? | 2 Yes | 4 No |
Answer / veda
example of global variable----
#include<stdio.h>
int a; /***global variable*********/
void main()
{
int s;
printf("\n enter the value of a--");
scanf("%d",&a);
s=a+3;
printf("\n s=%d",a);
mul(); /****another function********/
getch();
void mul()
{
int m;
m=a*2;
printf("\n m=%d",a);
}
output---
enter the value of a----5
s=8
m=10
when u r compaing this program in lnux we get a waring
because in linux default type is integer so in calling
function we r giving void so internally compailer treate as
a int so,
here type declaration is impartent
Is This Answer Correct ? | 21 Yes | 25 No |
Answer / mayank
COMMAND LINE ARGUMENT IN C:::
THE ARGUMENT THAT WE PASS ON TO MAIN() AT THE COMMAND PROMPT
ARE CALLED COMMAND LINE ARGUMENT .........
Is This Answer Correct ? | 6 Yes | 13 No |
Answer / k.anil kumar
AUTO IS A DEFAULT SPECIFIER.THERE IS NO NECESSARY TO
MENTION IT.STATIC FOR LOCAL ANG GLOBAL IS DIFFERENT.STATIC
LOCAL REMAINS KNOWN ONLY TO THE BLOCK WN WHICH IT IS
DECLARED.STATIC GLOBAL IS KNOWN ONLY TO THE FILE.IT IS NOT
SUBJECTED TO ANY SIDE EFFECTS.EXTERN IS JUST A DECLARATION
BUT NOT DEFINITION.FOR INTEGERS AND CHARACTERS , THIS
TYPICALLY MEANS IN THE REGISTER OF THE CPU RATHER THAN IN
MEMORY,WHERE NORMAL VARIABLES ARE STORED.
Is This Answer Correct ? | 27 Yes | 68 No |
what is the role you expect in software industry?
What is the difference between text and binary i/o?
What are dangling pointers? How are dangling pointers different from memory leaks?
what is the meaning of 'c' language
Write a program of prime number using recursion.
while initialization of array why we use a[][2] why not a[2][]...?
write a program for 7*8 = 56 ? without using * multiply operator ? output = 56
what type of errors are checked during compilation
What is the difference between if else and switchstatement
What are the keywords in c?
write a program to count the no of repaeted words in a line?
Difference between Class and Struct.
13 Answers Ericsson, Motorola, Wipro,