I'm running a program in C++ on a Chromebook Penguin terminal. The program runs perfectly the first time, but on consecutive runs it acquires different results. I suspect that this is because the terminal remembers the variables from before. Is there any way to resolve this issue in my code?
This is most likely a problem with your code (such as relying on uninitialized variables, or more likely working with external files or other state that are not cleared before each run).
So, the answer is "yes", you can fix it in your code by identifying and fixing the bugs.
Have you tried running the program in a different environment such as a vanilla linux system? If not, it's probably a bit premature to put the blame on Chromebook penguin :-)