Not needed - the loop will always continue unless you specifically break itCode:while ( true ) { cout << "Enter name: "; cin >> NameEnter; if ( NameEnter != Name ) { cout << NameEnter << " is not a valid. Please try again. \n\n"; continue; } else if ( NameEnter == Name ) { break; } }
The first if determines that NameEnter is NOT Name, so it's got to be the same if that comparison is NOT true - so no need to compare again in a second else.
Like above, you are comparing something, and then comparing to see if it's the other variant - there are only two options: TypeAnswer is equal to KeyWord, or it is NOT equal - it must be one of those too - so you do not need to check the second option in the else, because we KNOW it is not the first option.Code:if ( Type_Answer == KeyWord ) { cout << "Welcome back "<< Name << endl; } else if ( Type_Answer != KeyWord ) {
--
Mats