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

1st Aug 2016, 11:44 AM
João Pedro
João Pedro - avatar
2 Respostas
+ 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.
1st Aug 2016, 12:00 PM
Cohen Creber
Cohen Creber - avatar
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.
1st Aug 2016, 12:26 PM
Shubhranil Chakraborty
Shubhranil Chakraborty - avatar