Question: Can you please explain to me what is wrong with my coding? I'm not getting the desired output. I have to create a grid of

Can you please explain to me what is wrong with my coding? I'm not getting the desired output. I have to create a grid of X's and O's and then invert them.

#include

using namespace std;

int main() {

int rows, columns,i,j;

cout << "Enter number of rows: ";

cin >> rows;

cout << rows << " ";

cout << endl;

cout << "Enter number of cols: ";

cin >> columns;

cout << columns << " ";

cout << endl;

for(i = 0;i

for(j = 0;j

if((i+j)%2 == 1) {

cout << "X";

}

else {

cout << "O";

}

if(j == columns-1)

cout << "| ";

else

cout << "| ";

}

cout << endl;

}

cout << "INVERTED:" << endl;

for (i = 0; i

for (j = 0;j

if((i+j)%2 == 1) {

cout << "O";

}

else {

cout << "X";

}

if(j == columns-1)

cout << " | ";

else

cout << " | ";

}

cout << endl;

}

}

===================MISMATCHFOUNDONLINE0003:===================

ACTUAL:O|~X|~O|~X|~O|~X|~O|

EXPECTED:X~|~O~|~X~|~O~|~X~|~O~|~X~|

======================================================

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!