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.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)