void play ()
{
int i;
char ans;
for (i=0; i<1; i++)
{
cout << question[i] << correctAnswer[i];
cout << "Please enter the best answer available." << endl;
cin >> ans;
if (ans = 'a','b','c','d')
toupper(ans);
if (ans == correctAnswer[i])
cout << "You are correct." << endl;
else
cout << "Wrong answer." << endl;
}
}
Even though my answer is correct, it still comes up with "Wrong answer." output. I have used cout << question[i] << correctAnswer [i] to check the input is correct.
In future please use Code tags around your code to make it easier to read.
Your problem is at if (ans = 'a','b','c','d')
The first problem is that = is used for directly assigning values, == is to compare 2 values. In this case you need to use == or else ans is always going to be equal to a.
The second problem is you can't compare them all at the same time. You need to do if (ans == 'a' || ans == 'b' || ans == 'c') etc