answersLogoWhite

0


Best Answer

For C Programming, the use of a static variable has two uses:

One reason is to hide the variable from other modules. The scope of the static variable is limited to the compilation unit that it is described in.

The second use of a static variable is to keep the value of the variable intact through the entire program execution unit.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why use static variable in programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you give values to variable?

it depend on the programming language u use. for instance in c, just decalre the variable and equal it to the value it is to take. eg. my_age=21; /*my_age is the decared variable and 21 is the assigned value*/ //for php $my_age=21; /*my_age is the decared variable and 21 is the assigned value*/ for strings (in php)eg. $my_age="none of ur business" /*$my_age is the variable and the string "none of ur business" is the assigned value*/


What is singleton class it's implementation?

"A class containing a static variable that stores a unique, and inaccesibleto external classes (private), intance of itself. The static variable isaccessed by a static method, with public access, usually called getIntance.The static variable is initiated by the static getInstance method thatvalidates wether or not the static variable already exits. If the staticvariable has not being initiated, a new instance of the class is createdand assigned to the static variable which reference is then returned by themethod. If the static variable was previously created, the method willreturn a reference to the static variable." 1A Singleton class is used when you wish to restrict instantiation of a class to only one object."Simple Singleton Pattern Example in AS3class Data{private static var dataInstance:Data;public static function getInstance():Data{if(!dataInstance) dataInstance = new Data();return dataInstance;}public function Data(){if(dataInstance) throw Error("instance exists, please use Data.getInstance()");}}" 21 [Daniel Guzman - AS3 Object Oriented Programming]2 [Daniel Guzman - AS3 Object Oriented Programming]


What phrase do you use to describe a cursor variable?

static reference type


What programming language does the PSP use?

c++


What programming language does minecraft use?

Java

Related questions

How do you give values to variable?

it depend on the programming language u use. for instance in c, just decalre the variable and equal it to the value it is to take. eg. my_age=21; /*my_age is the decared variable and 21 is the assigned value*/ //for php $my_age=21; /*my_age is the decared variable and 21 is the assigned value*/ for strings (in php)eg. $my_age="none of ur business" /*$my_age is the variable and the string "none of ur business" is the assigned value*/


How do you create static variables in PHP?

Use the "static" keyword to declare a static variable within a function like shown below. <?php function fun() { static $variable; static $another_variable = ''; } ?>


What is a Singleton class How do you write it?

"A class containing a static variable that stores a unique, and inaccesibleto external classes (private), intance of itself. The static variable isaccessed by a static method, with public access, usually called getIntance.The static variable is initiated by the static getInstance method thatvalidates wether or not the static variable already exits. If the staticvariable has not being initiated, a new instance of the class is createdand assigned to the static variable which reference is then returned by themethod. If the static variable was previously created, the method willreturn a reference to the static variable." 1A Singleton class is used when you wish to restrict instantiation of a class to only one object."Simple Singleton Pattern Example in AS3class Data{private static var dataInstance:Data;public static function getInstance():Data{if(!dataInstance) dataInstance = new Data();return dataInstance;}public function Data(){if(dataInstance) throw Error("instance exists, please use Data.getInstance()");}}" 21 [Daniel Guzman - AS3 Object Oriented Programming]2 [Daniel Guzman - AS3 Object Oriented Programming]


Is there a program that can help you make a programming language but you don't need to know a programming language?

No. In order to make or use a program or a programming language, you need to know a programming language.


What is singleton class it's implementation?

"A class containing a static variable that stores a unique, and inaccesibleto external classes (private), intance of itself. The static variable isaccessed by a static method, with public access, usually called getIntance.The static variable is initiated by the static getInstance method thatvalidates wether or not the static variable already exits. If the staticvariable has not being initiated, a new instance of the class is createdand assigned to the static variable which reference is then returned by themethod. If the static variable was previously created, the method willreturn a reference to the static variable." 1A Singleton class is used when you wish to restrict instantiation of a class to only one object."Simple Singleton Pattern Example in AS3class Data{private static var dataInstance:Data;public static function getInstance():Data{if(!dataInstance) dataInstance = new Data();return dataInstance;}public function Data(){if(dataInstance) throw Error("instance exists, please use Data.getInstance()");}}" 21 [Daniel Guzman - AS3 Object Oriented Programming]2 [Daniel Guzman - AS3 Object Oriented Programming]


what is the difference between final and static keywords?

static: we can use the keyword static either to method or to a variable. when we declare to a method,(eg: public static void main(String args[]),we can use this method without any object. when we use to a variable,there will be only one instance of that variable irrespective of how many objects that get created of that class. Final: Usage of final to method or to a variable makes them as constant. It's value cannot be changed...


Which should be use static variable or viewstate?

Your question makes no sense.


What phrase do you use to describe a cursor variable?

static reference type


Can you use C as OOPS?

No, it is a programming language.


Where we use the c language?

In computer-programming.


What is the use of c-language?

Programming, mainly.


Why are use c language?

For is it programming used.