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
 
implement OR gate without using any bitwise operator. Alcatel 1
read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the vlaue after executing this code? a.200 b.1 c.-1 d.50 TCS 4
write a program for odd numbers?   15
what would be the output of the following program? main() { int k = 123; char *ptr; ptr = &k; printf("%d",*ptr); }   4
matrix multiplication fails introspect the causes for its failure and write down the possible reasons for its failurein c language. TCS 4
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145] Calsoft 6
why 'c' is called middle level language.   2
regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression TCS 1
1. main() { printf("%d",printf("HelloSoft")); } Output? HCL 3
write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function. Temenos 5
what is the structure? TCS 4
What is 'makefile' in C langauage? How it be useful? How to write a makefile to a particular program?   2
 
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