Question: #include #include #include typedef struct piece Piece; struct piece { char color; //possible option {'R', 'B', 'Y', 'G'} char symbol; //possible option {'*', '^', '#',

 #include #include #include typedef struct piece Piece; struct piece { char

#include #include #include

typedef struct piece Piece;

struct piece { char color; //possible option {'R', 'B', 'Y', 'G'} char symbol; //possible option {'*', '^', '#', '$'} }; int areEqual(Piece p1,Piece p2); void printPiece(Piece p); int readPiece(Piece * p);

int main(int argc, char * argv[]){ Piece p1; Piece p2; printf("Enter 2 pieces: "); if (readPiece(&p1) == 0 || readPiece(&p2) == 0){ printf("Invalid Input"); return 1; } if (areEqual(p1, p2) == 1 ){ printPiece(p1); printf("equals"); printPiece(p2); printf(" "); } else if (areEqual(p1, p2) == 0 ){ printPiece(p1); printf("does not equal"); printPiece(p2); printf(" "); } }

// this function return 1 if they are equal and 0 otehrwise int areEqual(Piece p1,Piece p2){

if (p1.color == p2.color && p1.symbol == p2.symbol) { return 1; } else { return 0; }

}

// this function prints in this format : colour/symbol eg. R/* void printPiece(Piece p){ printf("%c/%c",p.color, p.symbol);

}

// check for valid if yes return 1 otherwise return 0 int readPiece(Piece * p){

if (scanf("%c %c", &p->color, &p->symbol) == 2){ getchar(); return 1; } else { return 0; } }

Make a copy of piece.c and name it board.c.Modify your program so it reads in 16 pieces and places each one in a cell on a board from left-to-right, top-to-bottom. It should then print out the board. For simplicity we assume all piece input is entered in the same format as the previous exercises with exactly 1 space between them. Your program should behave as follows /board Enter pieces: R* Y^ B# Y* Y* Y* Y* B* Y^ R^ B^ R* R# R# R^ B* Y/* Y/* Y/ B/ /A R/ B/A R/* Try to use a top-down design approach when you do this. This means that as you modify your main function, try to design the prototypes of any functions you need to use n and use them in your main function. Once your main function is finished, go and implement these functions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!