Soe Error Program Could Please Help Nb Use Global Variables Variables Declared Outside Bod Q43797862
i have soe error in this program could you please help me
N.B: The use of global variables (variables declared outside thebody of a function) is not needed
#include <stdio.h>
#include <stdlib.h>
void condition_check(void);
void player_turn(int);
void computer_turn(void);
void print_board(void);
int main(void)
{
int count = 0, stop = 0;
int choice;
printf(“Welcome to 5×5 Tic-Tac-Toe Gamen”);
printf(“1)Human player vs Human playern”);
printf(“2)Human player vs Computern”);
do
{
printf(“Enter 1 or 2 to select gameplay moden”);
scanf(“%d”,&choice);
}
while(choice!=1 && choice!=2);
if(choice==1)
{
print_board();
while(1)
{
player_turn(1);
condition_check();
if(stop == 1)
{
break;
}
player_turn(2);
condition_check();
if(stop == 1)
{
break;
}
}
}
if(choice==2)
{
print_board();
while(1)
{
player_turn(1);
condition_check();
if(stop == 1)
{
break;
}
computer_turn();
condition_check();
if(stop == 1)
{
break;
}
}
}
return 0;
}
void condition_check(void)
{
int count = 0, stop = 0;
count += 1;
char board[5][5]={{‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘},{”,’ ‘,’ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘,’ ‘,”}};
int i,j,count1,count2;
for(i=0;i<5;i++)
{
count1=0;
count2=0;
for(j=0;j<5;j++)
{
if(board[i][j]==’X’)
count1++;
if(board[i][j]==’O’)
count2++;
}
if(count1==5)
{
printf(“Game Over! nPlayer-1 wonn”);
stop=1;
return;
}
if(count2==5)
{
printf(“Game Over! nPlayer-2 wonn”);
stop=1;
return;
}
}
for(j=0;j<5;j++)
{
count1=0;
count2=0;
for(i=0;i<5;i++)
{
if(board[i][j]==’X’)
count1++;
if(board[i][j]==’O’)
count2++;
}
if(count1==5)
{
printf(“Game Over! nPlayer-1 wonn”);
stop=1;
return;
}
if(count2==5)
{
printf(“Game Over! nPlayer-2 wonn”);
stop=1;
return;
}
}
count1=0;
count2=0;
for(i=0;i<5;i++)
{
if(board[i][i]==’X’)
count1++;
if(board[i][i]==’O’)
count2++;
}
if(count1==5)
{
printf(“Game Over! nPlayer-1 wonn”);
stop=1;
return;
}
if(count2==5)
{
printf(“Game Over! nPlayer-2 wonn”);
stop=1;
return;
}
count1=0;
count2=0;
for(i=0;i<5;i++)
{
for(j=4;j>=0;j–)
{
if(board[i][j]==’X’)
count1++;
if(board[i][j]==’O’)
count2++;
}
}
if(count1==5)
{
printf(“Game Over! nPlayer-1 wonn”);
stop=1;
return;
}
if(count2==5)
{
printf(“Game Over! nPlayer-2 wonn”);
stop=1;
return;
}
if(count==25)
{
printf(“Game Over! nIt’s a Tie! n”);
stop=1;
return;
}
return;
}
void computer_turn(void)
{
//code not designed time is not sufficient
}
void player_turn(int player_no)
{
int row_idx,col_idx;
do
{
printf(“user-%d enter position to place yoursymboln”,player_no);
printf(“Enter row indexn”);
scanf(“%d”,&row_idx);
printf(“Enter column indexn”);
scanf(“%d”,&col_idx);
}
while(board[row_idx-1][col_idx-1]!=’ ‘);
if(player_no==1)
{
board[row_idx-1][col_idx-1]=’X’;
}
if(player_no==2)
{
board[row_idx-1][col_idx-1]=’O’;
}
print_board();
return;
}
void print_board(void)
{
char board[5][5]={{‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘},{”,’ ‘,’ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘,’ ‘,”}};
printf(” 1 2 3 4 5 n”);
printf(” +—+—+—+—+—+n”);
printf(“1 | %c | %c | %c | %c | %c|n”,board[0][0],board[0][1],board[0][2],board[0][3],board[0][4]);
printf(” +—+—+—+—+—+n”);
printf(“2 | %c | %c | %c | %c | %c|n”,board[1][0],board[1][1],board[1][2],board[1][3],board[1][4]);
printf(” +—+—+—+—+—+n”);
printf(“3 | %c | %c | %c | %c | %c|n”,board[2][0],board[2][1],board[2][2],board[2][3],board[2][4]);
printf(” +—+—+—+—+—+n”);
printf(“4 | %c | %c | %c | %c | %c|n”,board[3][0],board[3][1],board[3][2],board[3][3],board[3][4]);
printf(” +—+—+—+—+—+n”);
printf(“5 | %c | %c | %c | %c | %c|n”,board[4][0],board[4][1],board[4][2],board[4][3],board[4][4]);
printf(” +—+—+—+—+—+n”);
return;
}
Expert Answer
Answer to i have soe error in this program could you please help me N.B: The use of global variables (variables declared outside t…
OR