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
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
Related questions
Question
C Programming .
Could you correct my code. Please attach a picture of the code. Thanks!
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;
}
}
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education