I have to write a C program for players to play chess. I was able to project the chessboard on the screen but I'm having trouble moving the pieces. I just need a few movements for these pieces. I need help with this. I'm writing my own code here ; #include int main() { printf("Chess Board : "); printf("\n"); int i,j,k; char column_name[9] = {'A','B','C','D','E','F','G','H','\0'}; char chess[9] = {'R', 'K', 'B', 'Q', 'G', 'B', 'K', 'R', '\0'}; for(i=8; i>0; i--) { printf("%d ", i); for(j = 1; j<9; j++) { if(i==8) { printf("B%c ",chess[j-1]); } if(i==7) { printf("BP "); } if(i==2) { printf("WP "); } if (i==1) { printf("W%c ", chess[j-1]); } if(i==3||i==4||i==5||i==6) { printf(" 0 "); } } printf("\n"); } //here i will be 0 then write column names for (j=1; j<9; j++) { printf(" "); printf("%c", column_name[j-1]); } return 0; } Please help me with the code I need to include in this code.
I have to write a C program for players to play chess. I was able to project the chessboard on the screen but I'm having trouble moving the pieces. I just need a few movements for these pieces. I need help with this. I'm writing my own code here ;
#include <stdio.h>
int main() {
printf("Chess Board : ");
printf("\n");
int i,j,k;
char column_name[9] = {'A','B','C','D','E','F','G','H','\0'};
char chess[9] = {'R', 'K', 'B', 'Q', 'G', 'B', 'K', 'R', '\0'};
for(i=8; i>0; i--)
{
printf("%d ", i);
for(j = 1; j<9; j++)
{
if(i==8)
{
printf("B%c ",chess[j-1]);
}
if(i==7)
{
printf("BP ");
}
if(i==2)
{
printf("WP ");
}
if (i==1)
{
printf("W%c ", chess[j-1]);
}
if(i==3||i==4||i==5||i==6)
{
printf(" 0 ");
}
}
printf("\n");
}
//here i will be 0 then write column names
for (j=1; j<9; j++)
{
printf(" ");
printf("%c", column_name[j-1]);
}
return 0;
}
Please help me with the code I need to include in this code.
Step by step
Solved in 3 steps with 1 images