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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started