Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (cavazos_899579):

How do I reuse the same variable in a loop for summing up numbers from any file?

OpenStudy (cavazos_899579):

OpenStudy (rsmith6559):

Just re-initialize it.

OpenStudy (kva1992):

or you could declare a global variable.

OpenStudy (rsmith6559):

You'd still need to re-initialize (set it to it's initial value) it.

OpenStudy (kva1992):

Or you could use another variable in the for loop and set it to the global variable it Would be easier when you start using for loops in bigger projects

OpenStudy (kva1992):

But yeah essential you would if you take that route

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!