ALLInterview.com :: Home Page KalAajKal.com
 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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
1.what are local and global variables?
2.what is the scope of static variables?
3.what is the difference between static and global variables?
4.what are volatile variables?
5.what is the use of 'auto' keyword?
6.how do we make a global variable accessible across  files?
Explain the extern keyword?
7.what is a function prototype?
8.what does keyword 'extern' mean in a function declaration?
 Question Submitted By :: Avula_sujatha@yahoo.co.in
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?
Answer
# 1
LOCAL variables:
       these variables are also called as auto variables....
this will be having life only inside a particular block.
 for ex:
           int i=45;
           {
              i=34;
printf("%d",i);
}
          printf("%d",i);
here the output will be for 1st printf  it will be 34 & for
second will be 45. since 34 is local to that block of
coding.. after it comes out it dies. the default value is
garbage value.

GLOBAL variables:
          these are those variables which will have life
until the program ends.... the scope will be throught....
it must be declared outside the first executable
statement... the default value is 0;. but when it comes to
prority wise local only will get the first place.......
for ex:
int i=21;
void main()
{
int i=99;
{
printf("%d",i);
}
printf("%d",i);
printf("%d",i);
}
the output will be for 1st printf it will print as 99.. for
second also 99 since local variable gets the first
prority.... then the last printf will print 21.

STATIC variables:
           the scope of the static variables is with in the
particular block of code. for ex:
main()
{
for(static int i=0;i<3;)
i++;
i=34;
printf("%d",i);
}

this wont print 'i' as 34... this will give an error that
UNDEFINED SYMBOL 'i'. since when 'i' comes out this will
dies... this 'i' cant be referred by the compailer.. but
this will work when we do it in other way::
void main()
{
static int i=0;
for(;i<3;)
i++;
i=34;
printf("%d",i);
}
          this will print i=34..... since we have defined as
static inside main block.... instead of FOR block ... till
main block prevails this i wont die..... so i=34 prints.

STATIC                                     GLOBAL
1)this must be declared            must be declared outside
inside the main function only       main only
2)this is one time                 but here it will take the
initilization...                   last initilization
3)this is local to a block         this has life til the 
                                   coding ends

AUTO:
this is as equal as local variables..... as mentioned for
local variables above

EXTERN:
this is declaration for global variable.. this can also be
declared as:
extern int i;
main()
{
----
---
}

FUNCTION PROTOTYPE:
this says a outer layer of  , how the function definition of
the above prototype lies......
 
Is This Answer Correct ?    2 Yes 0 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
#define min((a),(b)) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i);}  3
why division operator not work in case of float constant?  1
Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i; Output of i after executing the program Mascot4
Who had beaten up hooligan "CHAKULI" in his early college days?  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 TCS2
What does the message "warning: macro replacement within a string literal" mean?  1
how to implement stack operation using singly linked list  1
writw a program to insert an element in the begning of a doubly linked list  1
Which of the Following will define a type NODE that is a node in a Linked list? A)struct node {NODE*next;int x;};type def struct node NODE; B)typedef struct NODE {struct NODE *next;int x;}; C)typedef struct NODE {NODE *next;int x;}; D)typedef struct {NODE *next;int x;}NODE; Accenture4
What are the preprocessors? HP6
the format specified for hexa decimal is a.%d b.%o c.%x d.%u TCS4
without using arithmatic operator solve which number is greater??????????  1
simple c program for 12345 convert 54321 with out using string  5
main is a predefined or user define function if user defined why? if predefined whay? TCS2
define function Assurgent4
main() { int arr[5]={23,67}; printf("%d%d%d",arr[2],arr[3],arr[4]); } TCS6
Write a program to remove the C comments(/* */) and C++ comments(//) from a file. The file should be declared in command line. Subex2
I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.  1
what are the general concepts of c and c++  1
write a C code To reverse a linked list Motorola2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com