English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Can someone giveme a brief but very large description of what a variable is in programming including theories how it works and obviously some examples.
P.S Best answer will be given!!

2007-09-20 08:05:53 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

Instead of answering your homework/test question with something the teacher can trace, I'll point you to a resource that you can use to build your own answer.

2007-09-20 08:10:47 · answer #1 · answered by Jim Maryland 7 · 0 0

I don't why the length of the answer is an issue, but a variable in programming holds a value. What that value can be depends on the TYPE of variable it is.

Just like in math you have variables, say x and y. Then give them values. x=5, y=8.
In programming the TYPE of variable determines what value it is. There are several TYPES in programming:
int (integer)
float (real number>decimals)
double (larger float numbers can be held)
char (single characters)
String (group of characters)

So you could have :
TYPE Value
int 5
float 1.5
You could not have
TYPE Value
int 6.75
Because that is not an integer value.

Once your variable has a value, you use the variable in your equations, or for printing etc.
Hope this helps

2007-09-20 15:14:58 · answer #2 · answered by ? 6 · 0 0

Ex.

double myNumber = 10.90;

double here is the data type;
myNumber is the variable;
and 10.90 is the value.

That line assigns the value 10.90 to myNumber. In short, a variable is a storage for your values. This may be any combination of alphanumeric and some(limited) special characters(_, $). The rules in naming variables depend on the programming language you are using. Also, you can't use keywords as variable names.

2007-09-20 15:19:06 · answer #3 · answered by vilma v 2 · 0 0

fedest.com, questions and answers