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                      
tip   To Refer this Site to Your Friends   Click 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
what are the static variables
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what are the static variables
Answer
# 1
static variables are those which retains the outcoming 
value after 'n' iterations(initialized once)

(see below)
#include <stdio.h>

int g = 10;  

main(){

    int i =0; 
    void f1();
    f1();            
    printf(" after first call \n");
    f1();            
    printf("after second call \n");
    f1();            
    printf("after third call \n");

}
void f1()
{
    static int k=0;  //static variable
    int j = 10;  //auto variable           
    printf("value of k %d j %d",k,j);
    k=k+10;
}


the output will be:

value of k 0 j 10 after first call
value of k 10 j 10after second call
value of k 20 j 10after third call

hope this will help u....
 
Is This Answer Correct ?    5 Yes 1 No
Prakash.m
 
  Re: what are the static variables
Answer
# 2
I have a doubt..what is the difference between.."static" 
and "constant(const)"??
 
Is This Answer Correct ?    2 Yes 0 No
Subha Raman
 
 
 
  Re: what are the static variables
Answer
# 3
enum
 
Is This Answer Correct ?    0 Yes 1 No
Guest
 
  Re: what are the static variables
Answer
# 4
a static variable is shared by all the the instances of a
class.
 
Is This Answer Correct ?    0 Yes 1 No
Nitin Gupta
 
  Re: what are the static variables
Answer
# 5
Variables that statically retain their memeory location 
across function calls or in other words even beyond their 
scope. 

Global static values or functions are used to hide them 
from other files in the program.
 
Is This Answer Correct ?    0 Yes 1 No
Guest
 
  Re: what are the static variables
Answer
# 6
Static vairiable is one which can be accessed without 
creation of an object of Class i.e. by direct calling calss.
 
Is This Answer Correct ?    5 Yes 0 No
Nil
 
  Re: what are the static variables
Answer
# 7
static variables are variables that are initiated only once 
in a memory,suppose u have initiated a variable as static 
everytime u visit a iteration the value is changed 4m the 
initialised value,not like auto variables where the values 
remain same everytime u visit a iteration
 
Is This Answer Correct ?    2 Yes 0 No
Smriti Patnaik
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
plz answer..... a program that reads non-negative integer and computes and prints its factorial  2
write a “Hello World” program in “c” without using a semicolon?  3
C program to find frequency of each character in a text file?  3
True or false: If you continuously increment a variable, it will become negative? 1) True 2) False 3) It depends on the variable type  5
what is output of the following statetment?Printf(“%x”, -1<<4); ?  3
can we print any string without using terminator? Infosys2
In scanf h is used for BFL2
What is the memory allocated by the following definition ? int (*x)(); ADITI2
Will Macros support multiple arguments ? Oracle7
What are Storage Classes in C ? HP15
10. Study the code: void show() main() { show(); } void show (char *s) { printf("%sn",s); } What will happen if it is compiled & run on an ANSI C Compiler? A)It will compile & nothing will be printed when it is executed B)it will compile but not link C)the compiler will generate an error D)the compiler will generate a warning Accenture4
Software Interview Questions CAT1
What is the Difference between Class and Struct? Motorola9
void main() { int i=5; printf("%d",i++ + ++i); } ME11
what is the associativity of bitwise OR operator?  1
what is volatile in c language? TCS1
How to access or modify the const variable in c ? HP4
how to implement stack operation using singly linked list  1
write a program structure to find average of given number  1
What is #pragma directive?how it is used in the program? what is its advantages and disadvantages?  1
 
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