//Validating calculation type
while(userChar != false)
{
if(type == 'a')
{userChar = false;}
else if (type == 's')
{userChar = false;}
else
{
userChar = true;
cout << "You have entered an invalid character, a or s in lowercase only." << endl;
cin >> type;
}
}
I had incorporated this code into my first C++ tutorial and it works well, but I believe there is a shorter way to represent these line of codes. I am thinking of using 'or' statement, but I could not get the syntax right. I tried "while(type != 'a'||'s')" but to no avail. Any help would be appreciated, thank you!