answersLogoWhite

0

declaring a variable before main() will be accessed in main as well as in function which is called a "global variable" or "external variable".

*edit* a very good programming practice, which is also necessary with some compilers, is to declare the variable inside the function as well with the extern declaration before the type declaration.

for example if you had this inside a function:

int func(){

int x = 0;

x++;

return x;

}

that would be fine, but to declare it externally, you should include extern inside the function

int x = 0;

int func(){

extern x;

x++;

return x;

}

assuming that we declared the variable globally, which we did.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do yow swap two variables in java using a function?

You can swap two variables, by storing one of them temporarily in a third variable, like this: temp = a; a = b; b = temp; Inside a function, this won't work, because the function parameters are COPIES of the original variables, not the variables themselves. Any change won't affect the original variables. If you work with OBJECTS, and swap the CONTENTS of the objects (not the object pointers), it can work, though.


Why are function notation important?

A function is a relationship between quantities (variables) that occurs when the value of one of the quantities can be given uniquely by specified values of the other quantities. The variables involved can be either independent or dependent. The values of certain variables are fixed while others are allowed to change. The fixed variables are called the independent variables, and the dependent variables are those that change in response to the given value of the independent variable. A function therefore relates dependent variables to independent variables, the only restriction being that each value of the dependent variable is given uniquely by one, and only one, value for each of the independent variables.


Suppose an external variable is defined outside of function A and accessed within the function Does it matter whether the external variable is defined before or after the function. Explain?

No the two work together REALLY


Will a baseball career make you work inside or outside?

Both


What is the value that determines how an Excel function should be used?

A function will have a name, brackets and inside the brackets certain values will be needed, depending on the function. Some functions, like NOW(), do not need anything inside the brackets. Most functions have a set number of values needed in the function, and many have ones that are optional.


How does magnetism make a television work?

There's no function inside a TV set that requires magnetism to make it work.


Why do my employees keep standing outside on restaurant city?

make them work as cleaners, i think that will work and make them go inside


Are a group of tissues that work together to perform a specific function?

Groups of tissues that work together to perform a specific function make up organs. These organs then make up systems.


Can I buy something to make my speakers work wirelessly outside?

Yes, there are wireless speakers that will work outside. Try Audio Unlimited Wireless Speakers .


How can you tell amylase is an exoenzyme and not an endoenzym?

Endoenzymes work inside a cell. Exoenzymes work outside a cell after being secreted. Amylase is an exoenzyme because it's function is to break down starches in the mouth and GI tract. If it were an endoenzyme it would not function in this capacity.


Which one of these is not a function of sound in theatre?

*Make work for the union members


Do tissues work together with other structures to perform a function?

No. Tissues work together to make organs. Organs work together to make the organ system