ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2248)
 C++ interview questions  C++ Interview Questions (1106)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (644)
Question
What are Storage Classes in C ?
 Question Submitted By :: Leossk
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What are Storage Classes in C ?
Answer
# 1
There are four type of storage classes in C. These are used
to store variables. These are Extern, Static, Register and
Auto. Auto is the default class assigned to any variable.
eg. if we define int x=10; then it means auto int x=10
register and static differ in only one grounds that
register is there in the cpu and static in the main memory.
extern is global and can be accessed by any program and
anywhere.
 
Is This Answer Correct ?    648 Yes 56 No
Shashi Sourabh Kant
 
  Re: What are Storage Classes in C ?
Answer
# 2
there are 4 types of storage classes.they are-
extern,auto,register,static.
 
Is This Answer Correct ?    416 Yes 49 No
Santhi
 
 
 
  Re: What are Storage Classes in C ?
Answer
# 3
C has three types of storage: automatic, static and
allocated.

Variable having block scope and without static specifier
have automatic storage duration.

Variables with block scope, and with static specifier have
static scope. Global variables (i.e, file scope) with or
without the the static specifier also have static scope.

Memory obtained from calls to malloc(), alloc() or realloc()
belongs to allocated storage class.

--
http://www.geocities.com/vijoeyz/faq/



 
Is This Answer Correct ?    27 Yes 282 No
Vijoeyz
 
  Re: What are Storage Classes in C ?
Answer
# 4
There are two storage classes : Automatic and Static.

Automatic objects are local to block,and are discarded on
exit from the block.Declaration with in a block create
automatic objects if no storage class spections is
mentioned , or if the auto specifier is used.Object
declared as register are automatic,and are (if Possible)
stored in fast registers of the machine.

Static obj may be local to a block or external to all
blocks,but in either case retain their values across exit
from and reentry to function and blocks.Within a block
including a block that provides the code for a function,
static objects are declared with the keyword Static.
The objects declared outside all blocks,at the same level
as function definitions,are always static keyword;this
gives them Internal Linkage.
They become global to an entire program by omitting an
explicit storage class ,or by using keyword Extern;this
gives external linkage.
 
Is This Answer Correct ?    44 Yes 165 No
Babu
 
  Re: What are Storage Classes in C ?
Answer
# 5
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 67 No
K.anil Kumar
 
  Re: What are Storage Classes in C ?
Answer
# 6
According to denis ritchie there are 5 types of storage classes
1. auto
2.static
3.register
4.extern
5. typrdef


you all know about the abobe 4 types but in typedef is
actually not used as a storage class . but when it combines
with a variable it comes to the resolution
'
 
Is This Answer Correct ?    122 Yes 43 No
Pranab Kumar Rana
 
  Re: What are Storage Classes in C ?
Answer
# 7
Basically, storage classes in c are there to define the
storage & scope of the various sorts of variables.
we r having following 4 storage classes in C.
01.auto
02.register
03.extern
04.static
In this auto & register has local scope releted to block &
extern & static has global scope to main program.
 
Is This Answer Correct ?    115 Yes 21 No
Thomas
 
  Re: What are Storage Classes in C ?
Answer
# 8
#include<stdio.h>

void main()
{
int a,s; /*** local variable****/
printf("\n enter the value of a---");
scanf("%d",&a);
s=a+2;
printf("s=%d",a);
getch();
}



output--

enter the value of a--- 5
s=7




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


///*********************************////
 
Is This Answer Correct ?    69 Yes 27 No
Ajith
 
  Re: What are Storage Classes in C ?
Answer
# 9
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 ?    20 Yes 25 No
Veda
 
  Re: What are Storage Classes in C ?
Answer
# 10
write short note on command line arguments? 
Is This Answer Correct ?    15 Yes 38 No
Shweta
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
how to set Nth bit of variable by using MACRO   3
write a program for even numbers? TCS 19
How do you access command-line arguments?   1
Program to find the absolute value of given integer using Conditional Operators N-Tech 5
How does free() know how many bytes to free?   8
write a program that explain #define and # undef directive   1
What is the memory allocated by the following definition ? int (*x)(); ADITI 2
which one is highest Priority in c? a)=,b)+,c)++,d)==   4
which of the function operator cannot be over loaded a) <= b)?: c)== d)* HCL 10
to write a program, that finds the minimum total number of shelves, including the initial one, required for this loading process. The packets are named A, B, C, D, E &#133;&#133;.. Any numbers of packets with these names could be kept in the shelf, as in this example: [ZZLLAAJKRDFDDUUGGYFYYKK]. All packets are to be loaded on cars. The cars are lined in order, so that the packets could be loaded on them. The cars are also named [A, B, C, D, E,&#133;&#133;&#133;&#133;.]. Infosys 2
f() { int a=2; f1(a++); } f1(int c) { printf("%d", c); } c=? Geometric-Software 6
what is difference between array of characters and string Accenture 18
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com