Hello guys, I made some research on how to negate a boolean value but none seemed to work.
Ok, so I have the following code:
Code:
#include <iostream>
using namespace std;
int main()
{
bool Turn = true;
for (int i = 1; i < 11; i++)
{
if (Turn = true)
{
cout<<"X";
}
else if (Turn = false)
{
cout<<"O";
}
}
cin.get();
}
As of now the code prints "XXXXXXXXXX". And I want it to print "XOXOXOXOXO", so I tried 2 different things, which did not work:
Code:
#include <iostream>
using namespace std;
int main()
{
bool Turn = true;
for (int i = 1; i < 11; i++)
{
if (Turn = true)
{
cout<<"X";
}
else if (Turn = false)
{
cout<<"O";
}
Turn = !Turn;
}
cin.get();
}
AND:
Code:
#include <iostream>
using namespace std;
int main()
{
bool Turn = true;
for (int i = 1; i < 11; i++)
{
if (Turn = true)
{
cout<<"X";
}
else if (Turn = false)
{
cout<<"O";
}
if (Turn = true)
{
Turn = false;
}
else if (Turn = false)
{
Turn = true;
}
}
cin.get();
}
Ok so I made those changes so that the boolean 'Turn' would change everytime the loop executed. Guess it doesn't work. Can anyone give me a hand?