What is meant byStatic Variable ?

Answer Posted / rutuja gaikwad

static variable is a variable which declared inside class
using keyword static.
its value used only in that class not overall program


example:


#include <stdio.h>

void func() {
static int x = 0; // x is initialized only once
across three calls of func()
printf("%d\n", x); // outputs the value of x
x = x + 1;
}

int main(int argc, char * const argv[]) {
func(); // prints 0
func(); // prints 1
func(); // prints 2
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

sample and simple coding where we get?

1781


Write a program to find factorial of a number using functions

1246


What is %Type,%Rowtype?

1840


What is abstract Method i want the exact definition and is there any possibility to declare class as abstract without any abstract methods in that class?If it is possible then tell me why and how?

1472


WHAT IS MAIN IMPORTANT THING IN SOFTWARE?

1722






Difference between delegates and Events?

1714


Find out the list of roles which gives access to GUI activities? thanks in advance

1721


How to use string functions in QTP?give some examples

7117


how can we implement locks in plsql?

1790


how do we provide security for web services

1807


what is the current salary package in India for a lamp programmer

1874


what is the diffrence between software and hardware language?

1821


what is apt_dump_score in datastage where it is useful

1496


What is test execution and when will we start execution please send me one example for this question

1429


how many types of bytes are there???

1987