What is a variable?

What is a variable?

This question is important for philosophical reasons .

+4
variables
source share
5 answers

Wikipedia defines it as:

the symbolic name associated with the value and the value associated with it can be changed

I would say that this is a very strong general definition for a variable. If you want to expand it a bit, you can add that this value is represented by a block of system memory, but this slightly reduces generality.

I'm not sure that you will get a deeper definition if you hope so ...

+6
source share

Osborne Law: "Osborne Law: there will be no variables, no constants." :)

Wikipedia has entries for programming variables and mathematical variables

Variables in most programming languages ​​are mutable - these are buckets that can contain a piece of information with a symbolic name for a certain period of time.

In functional languages, such as XQuery or XSLT, they cannot be changed after assignment. The same goes for final variables in Java or const variables in most programming languages.

+5
source share

Symbol or name for a value. For example, in the expression

x + y

x and y are variables. Variables can represent numeric values, characters, character strings, or memory addresses.

Variables play an important role in computer programming, as they allow programmers to write flexible programs. Instead of entering data directly into the program, the programmer can use variables to represent the data. Then, when the program is executed, the variables are replaced with real data. This allows the same program to process different data sets.

Each variable has a name called a variable name and a data type. A variable data type indicates which value represents the value of a variable, for example, whether it is an integer, a floating-point number, or a character.

+1
source share

In programming, variables are placeholders that store values. These are perhaps the first building blocks of the program. Variables are how your program remembers values. For example, let's say you have a form that asks for the user's date of birth. Later you are going to make decisions with this date, for example, "should I show adult content to this user?" or "should I say happy birthday to this user today?" A variable called "birthDate" will allow you to store this information in memory until it makes these decisions.

Here is an example of pseudo-code of how a variable can be created.

 var birthDate = "1/1/1990" 

Decisions can be made about such a variable.

 if todaysDate - birthDate > 17years then showAdultContent 

In most languages, variables can also be changed. Say you want to track how many virtual poker games a user has won.

 if userWonThisGame then wins = wins + 1 
+1
source share

In C #, you declare a What variable as:

 object What; 

Your expression is like some kind of English programming language. Whether there is a? specify nullability value?

</lameAttemptAtHumour>

0
source share

All Articles