// I am not able to terminate the loop even if I enter x or X//
#include<iostream>
#include<string>
using namespace std;
int main()
{
string sc;
do
{
cout<<"Enter a code or x to exit: ";
cin>>sc;
}
while(sc != "x" || sc != "X");
return 0;
}
You need to use logical AND, not OR
eg:
if you enter "x":
sc != "x" is false
sc != "X" is true
false || true is true
the loop continues