0

what is the use of changing a variable value multiple times?

example: int a = 10; cout >> a; // = 10 a = 15; cout >> a; // = 15 // what could be the use of that in a real world program and by that i just mean, when this could be useful

8/1/2016 11:44:51 AM

João Pedro

2 Answers

New Answer

+2

I understand what you're asking, but there is no real answer to it. In real world programs, variables are created, changed, compared and deleted all the time. The frequency at which you change variables all just depends on what program you're actually creating. Some variables make require to be constantly changed to suit user needs, while some can just remain as a constant. But if you need to change a variable, you change it. No worries about how many times you're doing it.

0

it all depends on you or the objective of the program how many times you want to change the value. If you want to make a variable value constant just use the const keyword before the variable name.