C++/Do While Loop Problem
To start off, i'm very new so this could be an easy fix.
I use dev C++. let me just put the code.
using namespace std;
string string1="You are right!";
string string2="You are wrong!";
cout<<"What is the is North Carolina's Capital City?"<<endl<<endl;
if(answer =="Raleigh" || answer =="raleigh")
}while(answer !="Raleigh" || answer !="raleigh");
This runs, however it keeps running even after I enter Raleigh or raleigh. This does the same if I just make it a while() statement. I appreciate any help ;O)
} while( answer != "Raleigh" || answer != "raleigh" ) ;
} while( answer != "Raleigh" && answer != "raleigh" ) ;
and you would be ok.
the reason for the change should be obvious to you; if it is not, make sure that you can reason it out on your own - that is the way you learn.
also, prefer writing fully parenthesized sub-expressions as in:
while( ( answer != "Raleigh" ) && ( answer != "raleigh" ) ) ;
that way, you do not have to keep worrying about operator precedence all the time.