Question:
What is a variable???????
Null
2010-04-25 17:02:14 UTC
Sorry for asking. But i'm a newbie to programming


But when I read up about variables I still don't get what they do.. I know it stores data but why would it do it, what's the use in variables??

Thanks
Three answers:
Jonas
2010-04-25 17:07:55 UTC
You need variables for the same reason as you do in mathematics, to store values to be used in calculations.



For example, if I want print the numbers one to one hundred to screen, I would do a loop over a variable i ranging from 1 to 100:

for i from 1 to 100 step by 1:

print i

end for loop
RANGARAJAN S
2010-04-26 00:06:19 UTC
A variable is a place to store a piece of information. Just as you might store a friend's phone number in your own memory, you can store this information in a computer's memory. Variables are your way of accessing your computer's memory.



Variables are used to store dynamic data. Meaning they do not contain a constant value and can be dynamically changing according to the user inputs or program requirements.



For more information visit: http://www.intap.net/~drw/cpp/cpp03_01.htm



All the best!
mchl_the_citizen
2010-04-26 00:13:06 UTC
You have asked an important question.

When dealing with computers, we are dealing with representations. A variable tells the computer both what the meaning of a specific word or letter means as well as how it is supposed to be represented in your computer's memory. If your computer gets a simple phrase, such as (x+y)=2, your computer does not understand what x or y are until you tell it. x can vary in meaning to the computer, which is why it is called a variable.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...