So I’m making a program that asks a user if they want to do something. The answer is as simple as Y/N. I would like the program to be able to accept both capital and lowercase “Y”. Problem is, when I type while (answer == 'Y', answer == 'y') only the lowercase “Y” is accepted. If I type while (answer == 'y', answer == 'Y')
What am I doing wrong?
(More info: “answer” is the name of my “char” variable, and I’m using the “iostream”, “cstdlib”, and “string” libraries)
You need to use the ‘logical or’ operator
||So your code would become
while (answer =='Y' || answer == 'y')