To add on to that, a basic intrinsic value of having variables, as @TheIdeasMan said, is
from the user typing something on the keyboard |
Think of it this way: Why do we use credit cards instead of carrying around with us loads of bills, and a crapload of pennies, nickels, dimes, and quarters?
To address your examples, @OP, one of the few reasons why someone would choose to print out a statement as it is, such that
cout << "My favorite movie is Wheels of Fury";
is because they just want a one time message, and/or they don't really care for it.
Now, to address the first way. Think of a simple numbers calculation, for example:
1 2 3
|
int foo = 5;
int bar = 10;
int fooBar = foo*bar;
|
Now pretend you're a NASA scientist whose sole job is to calculate when the universe is going to shit on itself. You wrote a calculation program that's thousands of lines long. How many variables would you need? What if new research comes out and completely changes your formula around? Would you retype every number to the decimal?
HELL NO! You're going to go in, and adjust the values you set your variables to, so the functions they go in will still be in the same places, just with different numbers used to calculate things.