what are the static variables

Answers were Sorted based on User's Feedback



what are the static variables ..

Answer / nil

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 ?    9 Yes 0 No

what are the static variables ..

Answer / prakash.m

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 ?    7 Yes 3 No

what are the static variables ..

Answer / smriti patnaik

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 ?    4 Yes 0 No

what are the static variables ..

Answer / nitin gupta

a static variable is shared by all the the instances of a
class.

Is This Answer Correct ?    2 Yes 1 No

what are the static variables ..

Answer / subha raman

I have a doubt..what is the difference between.."static"
and "constant(const)"??

Is This Answer Correct ?    2 Yes 2 No

what are the static variables ..

Answer / mahendranath reddy ,cudpha

static int xx;

Is This Answer Correct ?    0 Yes 0 No

what are the static variables ..

Answer / guest

enum

Is This Answer Correct ?    0 Yes 2 No

what are the static variables ..

Answer / guest

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 2 No

Post New Answer

More C Interview Questions

#include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain &#1567;&#1567;&#1567;

4 Answers  


What are extern variables in c?

0 Answers  


How can I trap or ignore keyboard interrupts like control-c?

0 Answers  


int main() { int days; printf("enter days you are late"); scanf("%d",days); if (days<=5) printf("5o paisa fine"); if (days<=10&&days>=6) printf("1rs fine"); if(days>10) printf("10 rs fine"); if(days=30) printf("membership cancelled"); return 0; } tell me whats wrong in this program? is it right?

2 Answers  


3. When do you say that a digraph is acyclic A)if and only if its first search does not have back arcs B)a digraph is acyclic if and only if its first search does not have back vertices C)if and only if its first search does not have same dfnumber D)None of these

0 Answers   Accenture,






When should a type cast be used?

0 Answers  


What is the use of f in c?

0 Answers  


Write a c program to demonstrate character and string constants?

0 Answers  


printf("%d",(printf("Hello")); What it returns?

32 Answers   TCS,


write C code to reverse a string such that if i/p is "abc defg hij klmno pqrs tuv wxyz" and the o/p should be "cba gfed jih onmlk srqp vut zyxw"

2 Answers  


What is bash c?

0 Answers  


Why is c so important?

0 Answers  


Categories