Question
Continue this assignment using the code and follow the intructions below #include //This is a statement which tells the compiler to insert the contents of
Continue this assignment using the code and follow the intructions below
#include
int main(void) //This is basically just the name of main function which is predefined function in C library and void implies no input arguments.
{ float player_1_score; // This declaring the player 1 score as a float. float player_2_score; // This declaring the player 2 score as a float. float increment; // This declaring the increment score as a float.
char player_1_first_name[20]; // returns the character value player 1 first name char player_1_last_name[20]; // returns the character value char player_2_first_name[20]; // returns the character value char player_2_last_name[20]; // returns the character value
setbuf(stdout,NULL); // used for windows
printf("Enter player1's first name?:"); // Prompt user to enter player 1 first name scanf("%s",player_1_first_name); //scanf reads the input value and saves it. printf("Enter player1's last name:"); // Prompt user to enter last name scanf("%s", player_1_last_name); //scanf reads the input value and saves it printf("Enter player2's first name"); // Prompt user to enter first name scanf("%s", player_2_first_name); //scanf reads the input value and saves it. printf("Enter player2's last name"); // prompt user to enter player 2 first name. scanf("%s", player_2_last_name); // scanf reads the input value and saves it.
printf("Enter player1's score"); // prompts user to enter player'1s score. scanf("%f", &player_1_score); //scanf reads the input value and saves it.
printf("Enter player2's score"); // prompts user to enter player2's score. scanf("%f", &player_2_score); //scanf reads the input value and saves it.
printf("Enter size to increment scores scores by:"); // prompts user to enter the size to increment scores scanf("%f", &increment); //scanf reads the input value and saves it.
player_1_score = player_1_score + increment; // Mathematical operation which shows the addition of the increment to player1's score player_2_score = player_2_score + increment; // Mathematical operation which shows the addition of the increment to player1's score
printf("%s %s's score is: %.1f ", player_1_first_name, player_1_last_name,player_1_score); // The output on the screen given by print f printf("%s %s's score is: %.1f ", player_2_first_name, player_2_last_name,player_2_score); // The output on the screen given by print f
while(1) // This means the loop { //fill the board with . for(x=0;x printboard(array); //print the board printf(" Enter first X coordinate : "); // Prompts user to enter the first X coordinate scanf("%d",&x1); //scanf reads the input value printf(" Enter first Y coordinate : "); scanf("%d",&y1); //scanf reads the input value printf(" Enter second X coordinate : "); scanf("%d",&x2); // scanf reads the input value printf(" Enter second Y coordinate : "); scanf("%d",&y2); //scanf reads the input value array[y1-1][x1-1]='X'; // replacing the dot by x and filling the board on the input array[y2-1][x2-1]='X'; if(x1==x2) // The test if it is vertically aligned vertical=1; else vertical=0; if(y1==y2) // The test if it is horizontally aligned horizontal=1; else horizontal=0; if(x1+y1==x2+y2 || abs(x1-y1)==abs(x2-y2)) //The test if it is diagonally aligned diagonal=1; else diagonal=0; printf(" Horizonatlly Alligned = %d",horizontal); // The code determines the number associated with the horizontal printf(" Vertically Alligned = %d",vertical); // The code determines the number associated with the horizontal printf(" Diagonally Alligned = %d",diagonal); // The code determines the number associated with the horizontal printboard(array); //The code prints out the result board printf(" Enter an integer to continue(q to exit)"); // Prompts the User to enter an integer fflush(stdin); // flushes the output ch=getchar(); // gets the character if(ch=='q') // if condition break; // since running a while 1 loop we need a break point } return 0; // exit code } void printboard(char array[][BOARD_SIZE]) // Prints the board size on the output { int x,y; // separate function and needs a new initialization printf(" "); // new line statement for(x=1;x #include #include //Board Size Constant #define BOARD_SIZE 9 //Player CONSTANTS #define PLAYER1 1 #define PLAYER2 2 //Alignment Constants #define HOR_ALIGN 3 #define VERT_ALIGN 4 #define DIAG_ALIGN 5 int getAlignment(int, int, int, int); //Returns Alignment Constant void printBoard(int, int, int, int); //Prints Game Board int validateInput();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started