hello executable 4. Write the function playGame to do the following a. Return type void b. Empty parameter list c. Declare the following variables i. playerX, data type character array size 20 (i.e. use macro NAME); used to store the player's name that will be player X ii. playerO, data type character array size 20 (i.e. use macro NAME); used to store the player's name that will be player O iii. currentPlayer, data type integer; initialize to 1 (i.e. use macro PLAYER_X); ; used to keep track of the current player iv. loop, data type integer; initialize to 0 (i.e. use macro ZERO); used to control the number of loop iterations v. Write a printf statement to prompt player X to enter their name vi. Write a scanf statement to store player X's name in variable player X vii. Write a printf statement to prompt player O to enter their name viii. Write a scanf statement to store player O's name in variable playerO ix. Write a printf statement using the entered player names to play Othello x. Write a while loop to iterate four times (i.e. use macro FOUR) Test Case 1 Test Case 1 passes Test Case 2 Test Case 2 passes Test Case 3 Test Case 3 passes Test Case 4 Test Case 4 passes Test Case 5 Test Case 5 passes Test Case 6 Test Case 6 passes 1. Call function displayExplicit Board 2. If the current player (i.e. currentPlayer) is Player X (i.e. PLAYER_X) a. Write a printf statement to tell Player X it is their turn b. Switch players by setting current player to Player O 3. If the current player (i.e. currentPlayer) is Player O (i.e. PLAYER_O) a. Write a printf statement to tell Player O it is their turn b. Switch players by setting current player to Player X 4. Call function system(), pass as an argument explicit text "pause" (i.e. must include double quotes) to pause the console output 5. Increment the loop control variable (i.e. loop) by one Source compiles with no warnings Source compiles with no errors Source runs with no errors Source includes comments

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
C Programming. Could you correct my code. Please attach a picture of the code. Thanks!
Othello executable
4. Write the function playGame to do the following
a. Return type void
b. Empty parameter list
c. Declare the following variables
i. playerX, data type character array size 20 (i.e. use
macro NAME); used to store the player's name that
will be player X
ii. playerO, data type character array size 20 (i.e. use
macro NAME); used to store the player's name that
will be player O
iii. currentPlayer, data type integer; initialize to 1
(i.e. use macro PLAYER_X); ; used to keep track of
the current player
iv. loop, data type integer; initialize to 0 (i.e. use
macro ZERO); used to control the number of loop
iterations
v. Write a printf statement to prompt player X to enter
their name
vi. Write a scanf statement to store player X's name in
variable playerX
vii. Write a printf statement to prompt player O to
enter their name
viii. Write a scanf statement to store player O's name
in variable playerO
ix. Write a printf statement using the entered player
names to play Othello
x. Write a while loop to iterate four times (i.e. use
macro FOUR)
Test Case 1 Test Case 1 passes
Test Case 2 Test Case 2 passes
Test Case 3 Test Case 3 passes
Test Case 4 Test Case 4 passes
Test Case 5 Test Case 5 passes
Test Case 6 Test Case 6 passes
1. Call function displayExplicit Board
2. If the current player (i.e. currentPlayer) is
Player X (i.e. PLAYER_X)
a. Write a printf statement to tell Player X
it is their turn
b. Switch players by setting current
player to Player O
3. If the current player (i.e. currentPlayer) is
Player O (i.e. PLAYER_O)
a. Write a printf statement to tell Player O
it is their turn
b. Switch players by setting current
player to Player X
4. Call function system(), pass as an argument
explicit text "pause" (i.e. must include
double quotes) to pause the console output
5. Increment the loop control variable (i.e. loop)
by one
Source compiles with no warnings
Source compiles with no errors
Source runs with no errors
Source includes comments
Transcribed Image Text:Othello executable 4. Write the function playGame to do the following a. Return type void b. Empty parameter list c. Declare the following variables i. playerX, data type character array size 20 (i.e. use macro NAME); used to store the player's name that will be player X ii. playerO, data type character array size 20 (i.e. use macro NAME); used to store the player's name that will be player O iii. currentPlayer, data type integer; initialize to 1 (i.e. use macro PLAYER_X); ; used to keep track of the current player iv. loop, data type integer; initialize to 0 (i.e. use macro ZERO); used to control the number of loop iterations v. Write a printf statement to prompt player X to enter their name vi. Write a scanf statement to store player X's name in variable playerX vii. Write a printf statement to prompt player O to enter their name viii. Write a scanf statement to store player O's name in variable playerO ix. Write a printf statement using the entered player names to play Othello x. Write a while loop to iterate four times (i.e. use macro FOUR) Test Case 1 Test Case 1 passes Test Case 2 Test Case 2 passes Test Case 3 Test Case 3 passes Test Case 4 Test Case 4 passes Test Case 5 Test Case 5 passes Test Case 6 Test Case 6 passes 1. Call function displayExplicit Board 2. If the current player (i.e. currentPlayer) is Player X (i.e. PLAYER_X) a. Write a printf statement to tell Player X it is their turn b. Switch players by setting current player to Player O 3. If the current player (i.e. currentPlayer) is Player O (i.e. PLAYER_O) a. Write a printf statement to tell Player O it is their turn b. Switch players by setting current player to Player X 4. Call function system(), pass as an argument explicit text "pause" (i.e. must include double quotes) to pause the console output 5. Increment the loop control variable (i.e. loop) by one Source compiles with no warnings Source compiles with no errors Source runs with no errors Source includes comments
void playGame ()
}{
1
1
// variable for player names
char PlayerX = NAME;
char Player0 = NAME;
//variable for current player; black (X) always goes first
int current Player PLAYER_X;
// variable for loop control
int loop = ZERO;
// prompt and read in Player X name
printf("PlayerX, please enter your name\n", PlayerX);
scanf("%s", &PlayerX);
// prompt and read in Player X name
printf ("Playero, please enter your name\n", Player0);
scanf("%s", &Player0);
// prompt Player X and Player O to play othello
printf("%s and %s, let's play Othello!", PlayerX, Player0); // it won't print
// loop four iterations, two turns per player
while (loop < FOUR) {
}
// call function displayExplicitBoard
displayExplicitBoard();
//switch players for each move
currentPlayer == PLAYER_X;
// if the current player is Player X, prompt PlayerX it is their turn
// then switch to Player O
if (currentPlayer == PlayerX) {
}
printf("%s, it is your turn", PlayerX);
currentPlayer = PlayerO;
// if the current player is Player 0, prompt PlayerX it is their turn
// then switch to Player X
else{
}
printf("%s, it is your turn", Player0);
currentPlayer = PlayerX;__
// pause the console output
system("pause");
// increment the loop control variable
loop++;
Transcribed Image Text:void playGame () }{ 1 1 // variable for player names char PlayerX = NAME; char Player0 = NAME; //variable for current player; black (X) always goes first int current Player PLAYER_X; // variable for loop control int loop = ZERO; // prompt and read in Player X name printf("PlayerX, please enter your name\n", PlayerX); scanf("%s", &PlayerX); // prompt and read in Player X name printf ("Playero, please enter your name\n", Player0); scanf("%s", &Player0); // prompt Player X and Player O to play othello printf("%s and %s, let's play Othello!", PlayerX, Player0); // it won't print // loop four iterations, two turns per player while (loop < FOUR) { } // call function displayExplicitBoard displayExplicitBoard(); //switch players for each move currentPlayer == PLAYER_X; // if the current player is Player X, prompt PlayerX it is their turn // then switch to Player O if (currentPlayer == PlayerX) { } printf("%s, it is your turn", PlayerX); currentPlayer = PlayerO; // if the current player is Player 0, prompt PlayerX it is their turn // then switch to Player X else{ } printf("%s, it is your turn", Player0); currentPlayer = PlayerX;__ // pause the console output system("pause"); // increment the loop control variable loop++;
Expert Solution
Step 1

void playGame()

{

  char playerX[20]= NAME;

char playerO[20] = NAME; 

  int currentPlayer =1;

  int loop= ZERO; 

  printf("Hi PlayerX, Enter Your Name");

  scanf("%s", playerX);

  printf("Hi PlayerO, Enter Your Name")!

  scanf("%s", playerO);

  printf(" The name of the Players to Play Othello is %s and %s", playerX,playerO );

  while(loop <= FOUR)

  { 

    displayExplicitBoard();

if(currentPlayer == PLAYER_X)

 {

   printf(" Hi, PlayerX it's your turn");

   currentPlayer = PLAYER_O;

  } 

else 

  {

   printf(" Hi, PlayerO it's your turn");

   currentPlayer = PLAYER_X;

  } 

   system("pause"); 

  loop = loop + 1;

 

 }

}

       

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education