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

what is diff between localstatic and globalstatis variable possible 2 use in another file...?

2 Answers   HCL,


#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a==0.5) printf("yes"); else printf("no"); getch(); }

9 Answers   TCS,


In scanf h is used for

4 Answers   BFL,


Write a C/C++ program that connects to a MySQL server and checks intrusion attempts every 5 minutes. If an intrusion attempt is detected beep the internal speaker to alert the administrator. A high number of aborted connects to MySQL at a point in time may be used as a basis of an intrusion.

2 Answers   Drona Solutions, Infosys, Vodafone, Webyog,


What is c language & why it is used?

0 Answers  






write a program to find a given no. is divisible by 3 or not without using any arthimetic operators?

3 Answers   Broadcom, TCS,


24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?

2 Answers  


swap two integer variables without using a third temporary variable?

6 Answers   Persistent,


Write a program to reverse a linked list in c.

0 Answers   DELL, HAL,


Can true be a variable name in c?

0 Answers  


Explain about the constants which help in debugging?

0 Answers  


Can we change the value of static variable in c?

0 Answers  


Categories