Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include<iostream> using namespace std; char mat[3][3]; void matrix(); int main(

ID: 3611005 • Letter: #

Question

#include<iostream>
using namespace std;

char mat[3][3];
void matrix();

int main()

{int i,j;
for(i=0;j<3;i++)
   for(j=0;j<3;j++)
       mat[i][j]=' ';
matrix ();

int turns=1; //totalof 9 turns will be there
int row=0, column=0;
char c;

while(turns <=9)
    {

    if((turns%2) !=0)
        {
           cout<<"X's turn - Enter your move "<<"Row (1-3) andcolumn (1-3) seperated by a space: "<<endl;
           c='X';
           
        }
    else
        {
           cout<<"O's turn - Enter your move "<<"Row (1-3) andcolumn (1-3) seperated by a space: "<<endl;
           c='O';
        }

   
    cin>>row;
    cin>>column;
    if( (row <4) && (column <4))
        {
         if((mat[row-1][column-1] !='X') && (mat[row-1][column-1] !='O'))
            {
                   mat[row-1][column-1]=c;
                   matrix();
                   turns++;
            }
         else
            {
               cout<<"This postion has already been occupied by:"<<mat[row-1][column-1]<<endl;
               matrix();
            }
        }
    else
        {
           cout<<"Entered wrong number"<<endl;
        }
   

    }
return 0;
}


void matrix()
{int i;
for(i=0; i<3; i++)
     {cout<<" "<< mat[i][0]<<" | "<< mat[i][1] << " | "<< mat[i][2];  
       if(i!=2)
          cout<<" --- --- --- ";
     }
cout<<endl;
return;
}

Explanation / Answer

#include using namespace std; char mat[3][3]; void matrix(); int main(