i have just started learning and im trying to make a system that will ask the player if he wants tot play again but whenh the player inputs Y or N, it always just repaets whats in the while loop again even if the bool statment is false?
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int x,y;
char YN;
bool PA;
while (PA = 1) {
cout << "enter first number: ";
cin >> x;
cout << "please enter a number larger then the first: ";
cin >> y;
while (x <= y) {
cout << x << "\n";
x = x+1;
}
cout << "Would you like to play again? (y/n)";
cin >> YN;
if (YN == 'y') {
PA = 1;
} else {
PA = 0;
}
}
return 0;
}
No problem, Daniel. I still sometimes accidentally type the equality operator when I meant to use the assignment operator, though luckily not as often the other way around.