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

why we need to take u?

1672


What sysoption determines where the macro facility searches a specific catalog for complied macro?

1649


How to know we are in home page of a web application using QTP

1998


1) How can u create the table?

1372


can we allocate memory for interface? if no then why?

1468






hai i am prasanna.I am MCA 2009 fresher.tell me about certifications.which certification helps me to improve my carrier and to get a technically oriented job ,which certification helps to get job faster.

2014


in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'

1767


What is the merger sort principle and its time complexity.

635


how does database connection using ADO.NET?

1516


Which method protects back button to retrieve old value from previous page in Struts.

1444


how to convert the data from HTML file to SAS dataset?

2186


I want to insert date in the form of yyyy-mm-dd... if any changes happen while inserting date format want to show error meg...any one can solve this..??

1655


when will triggars the at new event in abap and web dybn pro?

1488


A good website has the following conditions It should be interactive. It should contain at least 20 images. Title cannot be null and should contain at least 10 letters other than spaces and hyphen (-). The keywords should contain atleast three among the following list : "design", "Graphics", "lovely", "beautiful", "amazing" and "mesmerising" Write a method: boolean isGoodWebsite(boolean isInteractive, int numOfImages, String title,String keywords[]) isInteractive whether the site is interactive or not numOfImages Number of images on the website title Title of the website keywords Array of keywords in the website.

1778


4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?

1891