I need help with this simple question.
I'm starting to learn more about while loops and I'm not sure what I'm doing wrong.
Here's a snippet of the code that I'm working on, so when I'm using or
in while loop the loop executes indefinitely. But when I use AND
the loop stops can somebody please explain? Shouldn't OR
be used instead as per definition?
void displayMenu() {
char option;
while (option != 'Q' or 'q') { //And or OR?
cout << "P - Print numbers" << endl;
cout << "A - Add a number" << endl;
cout << "M - Display mean of the numbers" << endl;
cout << "S - Display the smallest number" << endl;
cout << "L - Display the largest number" << endl;
cout << "Q- Quit" << endl;
cout << "Choose Your Option-" << endl;
cin >> option;
if (option == 'P' or 'p')
Print();
}
}