for (int i=0; i < 10; ++i) { // i is in scope and lifetime. } // i is out of scope and lifetime.
int i; ... for(int i = ...) { // the i of the for loop is in scope and lifetime. // the i of the outer code is in lifetime, but not scope. } // the i of the for loop is gone. // but the reader can be confused about this. i = 5;
bool keepGoing; keepGoing = GetContinue(); while (keepGoing) { string plainText; int shift; string criptText; plainText = GetMessage(); shift = GetShiftAmount(); cryptText = Encrypt(plainText,shift); PrintCode(criptText, plainText); keepGoing = GetContinue(); }