If statement not working

Hello guys I am a little bit confused on if statements.

I am creating a simple program that sorts numbers in descending order, and I have it so that it outputs the sorting to the screen, but I want to give the user the option to see the sorting process. Now the process works, but when the user inputs y/Y or n/N the program shows the sorting process, when it should only show it when the reply is y/Y.

void BubSort2 (double y [], int count)
{
void Trace (double [], int);

char reply;
double temp;
int blue, red;

blue = 1;

do // query for trace
{
system ("cls");
cout << setw (48) << "Initiate Trace?";
Skipline (2, c);
cout << setw (55) << "Enter y for yes or n for no: ";
cin >> reply;
}
while ((reply != 'n') && (reply != 'N') &&
(reply != 'y') && (reply != 'Y'));

system ("cls");

do
{
for (red = blue + 1; red >= 2; red--)
{
if (y [red] > y [red - 1])
{
temp = y [red];
y [red] = y [red - 1];
y [red - 1] = temp;

if ((reply = 'y') || (reply = 'Y'))
{
Trace (y, count);
}
}
}

blue++;
}
while (blue != count);

cin.get ();
return;
}
Last edited on
check your assignment versus equality operator.
Topic archived. No new replies allowed.