What is the point in variables, why wouldn't you just write out whatever number you assigned to it

what is the point in variables, why wouldn't you just write out whatever number you assigned to it

Attached: IMG_20180427_082529.jpg (1024x576, 62K)

Other urls found in this thread:

en.m.wikipedia.org/wiki/Variable_(mathematics)
twitter.com/NSFWRedditImage

What is the point in calling the president ”president”, why don’t we just use his name?

saves space in memory

If you see "24", can you immediately tell me what that means without context?

How about "HOURS_IN_DAY"?

You can also change the value without needing to do a global search and replace in every source file, which can also lead to false matches, when a number is used in two places but means different things ("24" in some places in code means the number of hours in a day, but it could also mean other things in other contexts)

It's in the name douchebag, 'variable', the value you assign to it is not fixed.

Depends on the language implementation, but often the same literal will point to the same place in memory as an optimization. This is why String == String sometimes appears to work in Java for example, when both strings are the same literal.

stupid question without thinking 0.2 secs about it

But HOURS_IN_DAY is not a variable. That is not what we are talking about.

If you mean constants and not variables, then the only real point is easily changing the value of a constant that is used in multiple lines. If you mean actual variables, variables have dynamic uses. For example, if you have two functions that take in a single variable and do wildly different operations to the variable, then both return the variable afterwards, you cannot do this with just static numbers. Pretty hard answering such a retarded question desu

HOW COME THE MOST RETARDED QUESTIONS ARE ALWAYS LINKED WITH Jow Forums IMAGES

It is though. I know in most procedural languages you would refer to this more specifically as a "constant", but that is a kind of variable.
en.m.wikipedia.org/wiki/Variable_(mathematics)

Jesus christ, did you finish high school math?

Because variables just hold the number/string/input you put in them so you just write it instead of typing each time

a = 1
b = "string"
c = input()


variables are nothing more than what they contain inside

For brainlets' convenience.

what kind of shirt is he wearing

>const char* x = "test";
Gorgeous, now what, numbnuts?

But I have no president...

You mean use the exact address of every ram location instead of giving them names?

>variables
You mean constants?

>just write out whatever number you assigned to it
OK, Pajeet, you do that and we focus on readable code.

gr8 b8 m8

to compile a program with every possible value of a variable would require running the program to find every possible value. then it enters P = NP / halting problem territory.