SlideShare a Scribd company logo
1 of 6
Download to read offline
Connect4.c
2. Include the string.h header file
3. Declare the following macros (i.e., use #define NOT const) to use
as global constants for the application
a. ROW with a value of 6
b. COL with a value of 7
c. ONE with a value of 1
d. TWO with a value of 2
e. SPACE with a value of ' ' (NOTE: there is an explicit
space between the open and close single quote)
f. TRUE with a value of 1
g. FALSE with a value of 0
4. Write the function declaration or prototype for functions
a. initializeBoard
b. displayBoard
c. makeMove
5. Update function playGame to do the following
a. Add local variable named board, data type character,
two-dimensional array, size 6 rows and 7 columns (i.e.,
use macros ROW and COL)
b. Before the while loop
i. Call function initializeBoard; pass as an argument
array board
c. Inside the while loop
i. Comment out or delete call to function
displayExplicitBoard
ii. Call function displayBoard; pass as an argument
array board
iii. Inside the if/else if statements
1. Replace the printf statement notifying the
player it is their turn with call to function
makeMove; pass as arguments
a. Character array of players name
(i.e., yellow or red)
b. 2-d array board
6. Write function initializeBoard to do the following
a. Return type void
b. Parameter list includes 2-d character array (i.e., board),
size 6 rows and 7 columns (i.e., use macros ROW and
COL)
c. Write a nested for loop to iterate through the rows and
columns of array board to do the following
i. Set the element at the current row and column in
the 2-d array board to an explicit space (i.e., use
macro SPACE)
7. Write function displayBoard to do the following
a. Return type void
b. Parameter list includes 2-d character array (i.e., board),
size 6 rows and 7 columns (i.e., use macros ROW and
COL)
c. Write printf statements to display the top row of the
Connect Four board
d. Write a nested for loop to iterate through the rows and
columns of array board to do the following
i. Write a printf statement to display the value
stored in the current element of the array board
8. Write function makeMove to do the following
d. Return type void
e. Parameter list includes
i. Character array for the players name (i.e.,
playerName, size is 20, use macro NAME)
ii. 2-d character array (i.e., board), size 6 rows and 7
columns (i.e., use macros ROW and COL)
f. Declare variable to store the user input for their move,
data type character array, size 2 (i.e., move, use macro
TWO)
g. Declare variable to store if player move is valid, data type
integer, initialize to 0 (i.e., valid, use macro FALSE)
h. Loop while the players move input is not valid (i.e.,
FALSE)
i. Write a printf statement to prompt the player to
enter their move
ii. Write a scanf statement to store the players move
in local variable move
iii. Write a printf statement to display to the player
the move they entered
iv. Declare variable to store the length of the players
move input, data type integer (i.e., length) set
equal to explicit type cast to integer of return value
from function call strlen(), pass as an argument
variable move
v. Evaluate variable length
1. If it is equal to 1, set variable valid equal to
true (i.e., use macros ONE and TRUE)
2. If it is not equal to 1, set variable valid
equal to false (i.e., use macros ONE and
FALSE)
vi. Evaluate variable valid, if it is false, write a printf
statement to notify the player their move input was
not valid (i.e., use macro FALSE)
Above are the instructions I need and below is what I currently have.
#include
#include
// global constants a.k.a. macros
#define NAME 20
#define YELLOW 1
#define RED 2
#define ZERO 0
#define FOUR 4
// function prototypes
void welcomeScreen ();
void displayEmptyBoard();
void playGame();
// main function
int main()
{
// call function welcomeScreen
welcomeScreen();
// call function displayEmptyBoard
// displayEmptyBoard();
// call function playGame
playGame();
// program executed successfully
return 0;
}
// welcomeScreen function displays the Connect Four logo and rules of the game
void welcomeScreen ()
{
printf (" CCCC OOOO N N N N EEEEE CCCC TTTTT FFFFF OOOO U
U RRRR n");
printf ("C O O N N N N N N EE C T F O O U
U R R n");
printf ("C O O N N N N N N EEEE C T FFF O O U
U R R n");
printf ("C O O N NN N NN EE C T F O O U
U R R n");
printf (" CCCC OOOO N N N N EEEEE CCCC T F OOOO UUUU
R R n");
printf ("n");
printf ("CONNECT FOUR GAME RULESnn");
printf("t 1. The board is 6 rows and 7 columns.n");
printf("t 2. The player with the yellow discs goes first.n");
printf("t 3. Players drop 1 disc in the grid at a time.n");
printf("t 4. Players alternate turns.n");
printf("t 5. Once a player has four discs in a row vertically, horizontally or
diagonally, they have won the game!n");
}
// function displayEmptyBoard displays a hardcoded version of an Connect Four board
void displayEmptyBoard()
{
printf("|------------------------------------------n");
printf("| A | B | C | D | E | F | G |n");
printf("|------------------------------------------n");
printf("|------------------------------------------n");
printf("| | | | | | | |n");
printf("|------------------------------------------n");
printf("| | | | | | | |n");
printf("|------------------------------------------n");
printf("| | | | | | | |n");
printf("|------------------------------------------n");
printf("| | | | | | | |n");
printf("|------------------------------------------n");
printf("| | | | | | | |n");
printf("|------------------------------------------n");
printf("| | | | | | | |n");
printf("|------------------------------------------n");
}
void playGame()
{
// store player names
char yellow[NAME]; // Karin
char red[NAME]; // Lia
// yellow (Y) always goes first
int currentPlayer = YELLOW;
int loop = ZERO;
printf("Player Yellow, please enter your namen");
scanf("%s", yellow);
printf("Player Red, please enter your namen");
scanf("%s", red);
printf("%s and %s, let's play Connect Four!n", yellow, red);
while(loop < FOUR)
{
// call function displayEmptyBoard
displayEmptyBoard();
// switch players for each move
if(currentPlayer == YELLOW)
{
printf("%s, it is your turnn", yellow);
// switch players
currentPlayer = RED;
}
else if(currentPlayer == RED)
{
printf("%s, it is your turnn", red);
currentPlayer = YELLOW;
}
loop++;
}
}
Please provide code screenshots in C language. Thank you

More Related Content

Similar to Connect4.c2. Include the string.h header file3. Declare the foll.pdf

Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfmanjan6
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...ssuserd6b1fd
 
The following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfThe following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfeyelineoptics
 
C programming session 01
C programming session 01C programming session 01
C programming session 01Dushmanta Nath
 
Objectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docxObjectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docxamit657720
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfAditya Kumar
 
Exercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdf
Exercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdfExercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdf
Exercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdffms12345
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick referenceArduino Aficionado
 
Core csharp and net quick reference
Core csharp and net quick referenceCore csharp and net quick reference
Core csharp and net quick referenceilesh raval
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfmohdjakirfb
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab ManualAkhilaaReddy
 

Similar to Connect4.c2. Include the string.h header file3. Declare the foll.pdf (19)

Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
 
The following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfThe following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdf
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
Objectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docxObjectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docx
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdf
 
Exercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdf
Exercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdfExercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdf
Exercise 1 (10 Points) Define a FixdLenStringList class that encaps.pdf
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
2 data and c
2 data and c2 data and c
2 data and c
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick reference
 
Core csharp and net quick reference
Core csharp and net quick referenceCore csharp and net quick reference
Core csharp and net quick reference
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
 
03-fortran.ppt
03-fortran.ppt03-fortran.ppt
03-fortran.ppt
 

More from shakilaghani

Directions Match Section A with Section B compete for cucumbers .pdf
Directions Match Section A with Section B compete for cucumbers .pdfDirections Match Section A with Section B compete for cucumbers .pdf
Directions Match Section A with Section B compete for cucumbers .pdfshakilaghani
 
Discuss the difference between the use of views and Transact-SQL sta.pdf
Discuss the difference between the use of views and Transact-SQL sta.pdfDiscuss the difference between the use of views and Transact-SQL sta.pdf
Discuss the difference between the use of views and Transact-SQL sta.pdfshakilaghani
 
Culture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdf
Culture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdfCulture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdf
Culture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdfshakilaghani
 
Create Your Brand Vision The first step to creating your personal bra.pdf
Create Your Brand Vision The first step to creating your personal bra.pdfCreate Your Brand Vision The first step to creating your personal bra.pdf
Create Your Brand Vision The first step to creating your personal bra.pdfshakilaghani
 
Create an excel file consisting of ten students� names in the follow.pdf
Create an excel file consisting of ten students� names in the follow.pdfCreate an excel file consisting of ten students� names in the follow.pdf
Create an excel file consisting of ten students� names in the follow.pdfshakilaghani
 
Compare and contrast indian culture with arab culture on the.pdf
Compare and contrast indian culture with arab culture on the.pdfCompare and contrast indian culture with arab culture on the.pdf
Compare and contrast indian culture with arab culture on the.pdfshakilaghani
 
Client A Moved from one side of the city to another and transitione.pdf
Client A Moved from one side of the city to another and transitione.pdfClient A Moved from one side of the city to another and transitione.pdf
Client A Moved from one side of the city to another and transitione.pdfshakilaghani
 
Choose the appropriate contraint type for what is descibed Field, T.pdf
Choose the appropriate contraint type for what is descibed Field, T.pdfChoose the appropriate contraint type for what is descibed Field, T.pdf
Choose the appropriate contraint type for what is descibed Field, T.pdfshakilaghani
 
Chapter 13 1. What is ontology 2. What is Realism 3. What is.pdf
Chapter 13 1. What is ontology 2. What is Realism 3. What is.pdfChapter 13 1. What is ontology 2. What is Realism 3. What is.pdf
Chapter 13 1. What is ontology 2. What is Realism 3. What is.pdfshakilaghani
 
ces ions mitochondria away from toward water thermoregulation osmore.pdf
ces ions mitochondria away from toward water thermoregulation osmore.pdfces ions mitochondria away from toward water thermoregulation osmore.pdf
ces ions mitochondria away from toward water thermoregulation osmore.pdfshakilaghani
 
Case Study Management Information System at Dell Management infor.pdf
Case Study Management Information System at Dell Management infor.pdfCase Study Management Information System at Dell Management infor.pdf
Case Study Management Information System at Dell Management infor.pdfshakilaghani
 

More from shakilaghani (11)

Directions Match Section A with Section B compete for cucumbers .pdf
Directions Match Section A with Section B compete for cucumbers .pdfDirections Match Section A with Section B compete for cucumbers .pdf
Directions Match Section A with Section B compete for cucumbers .pdf
 
Discuss the difference between the use of views and Transact-SQL sta.pdf
Discuss the difference between the use of views and Transact-SQL sta.pdfDiscuss the difference between the use of views and Transact-SQL sta.pdf
Discuss the difference between the use of views and Transact-SQL sta.pdf
 
Culture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdf
Culture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdfCulture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdf
Culture Change at IBMIBM began in 1914 as a maker of cheese slicer.pdf
 
Create Your Brand Vision The first step to creating your personal bra.pdf
Create Your Brand Vision The first step to creating your personal bra.pdfCreate Your Brand Vision The first step to creating your personal bra.pdf
Create Your Brand Vision The first step to creating your personal bra.pdf
 
Create an excel file consisting of ten students� names in the follow.pdf
Create an excel file consisting of ten students� names in the follow.pdfCreate an excel file consisting of ten students� names in the follow.pdf
Create an excel file consisting of ten students� names in the follow.pdf
 
Compare and contrast indian culture with arab culture on the.pdf
Compare and contrast indian culture with arab culture on the.pdfCompare and contrast indian culture with arab culture on the.pdf
Compare and contrast indian culture with arab culture on the.pdf
 
Client A Moved from one side of the city to another and transitione.pdf
Client A Moved from one side of the city to another and transitione.pdfClient A Moved from one side of the city to another and transitione.pdf
Client A Moved from one side of the city to another and transitione.pdf
 
Choose the appropriate contraint type for what is descibed Field, T.pdf
Choose the appropriate contraint type for what is descibed Field, T.pdfChoose the appropriate contraint type for what is descibed Field, T.pdf
Choose the appropriate contraint type for what is descibed Field, T.pdf
 
Chapter 13 1. What is ontology 2. What is Realism 3. What is.pdf
Chapter 13 1. What is ontology 2. What is Realism 3. What is.pdfChapter 13 1. What is ontology 2. What is Realism 3. What is.pdf
Chapter 13 1. What is ontology 2. What is Realism 3. What is.pdf
 
ces ions mitochondria away from toward water thermoregulation osmore.pdf
ces ions mitochondria away from toward water thermoregulation osmore.pdfces ions mitochondria away from toward water thermoregulation osmore.pdf
ces ions mitochondria away from toward water thermoregulation osmore.pdf
 
Case Study Management Information System at Dell Management infor.pdf
Case Study Management Information System at Dell Management infor.pdfCase Study Management Information System at Dell Management infor.pdf
Case Study Management Information System at Dell Management infor.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesSHIVANANDaRV
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 

Recently uploaded (20)

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 

Connect4.c2. Include the string.h header file3. Declare the foll.pdf

  • 1. Connect4.c 2. Include the string.h header file 3. Declare the following macros (i.e., use #define NOT const) to use as global constants for the application a. ROW with a value of 6 b. COL with a value of 7 c. ONE with a value of 1 d. TWO with a value of 2 e. SPACE with a value of ' ' (NOTE: there is an explicit space between the open and close single quote) f. TRUE with a value of 1 g. FALSE with a value of 0 4. Write the function declaration or prototype for functions a. initializeBoard b. displayBoard c. makeMove 5. Update function playGame to do the following a. Add local variable named board, data type character, two-dimensional array, size 6 rows and 7 columns (i.e., use macros ROW and COL) b. Before the while loop i. Call function initializeBoard; pass as an argument array board c. Inside the while loop i. Comment out or delete call to function displayExplicitBoard ii. Call function displayBoard; pass as an argument array board iii. Inside the if/else if statements 1. Replace the printf statement notifying the player it is their turn with call to function makeMove; pass as arguments a. Character array of players name (i.e., yellow or red)
  • 2. b. 2-d array board 6. Write function initializeBoard to do the following a. Return type void b. Parameter list includes 2-d character array (i.e., board), size 6 rows and 7 columns (i.e., use macros ROW and COL) c. Write a nested for loop to iterate through the rows and columns of array board to do the following i. Set the element at the current row and column in the 2-d array board to an explicit space (i.e., use macro SPACE) 7. Write function displayBoard to do the following a. Return type void b. Parameter list includes 2-d character array (i.e., board), size 6 rows and 7 columns (i.e., use macros ROW and COL) c. Write printf statements to display the top row of the Connect Four board d. Write a nested for loop to iterate through the rows and columns of array board to do the following i. Write a printf statement to display the value stored in the current element of the array board 8. Write function makeMove to do the following d. Return type void e. Parameter list includes i. Character array for the players name (i.e., playerName, size is 20, use macro NAME) ii. 2-d character array (i.e., board), size 6 rows and 7 columns (i.e., use macros ROW and COL) f. Declare variable to store the user input for their move, data type character array, size 2 (i.e., move, use macro TWO) g. Declare variable to store if player move is valid, data type integer, initialize to 0 (i.e., valid, use macro FALSE) h. Loop while the players move input is not valid (i.e., FALSE)
  • 3. i. Write a printf statement to prompt the player to enter their move ii. Write a scanf statement to store the players move in local variable move iii. Write a printf statement to display to the player the move they entered iv. Declare variable to store the length of the players move input, data type integer (i.e., length) set equal to explicit type cast to integer of return value from function call strlen(), pass as an argument variable move v. Evaluate variable length 1. If it is equal to 1, set variable valid equal to true (i.e., use macros ONE and TRUE) 2. If it is not equal to 1, set variable valid equal to false (i.e., use macros ONE and FALSE) vi. Evaluate variable valid, if it is false, write a printf statement to notify the player their move input was not valid (i.e., use macro FALSE) Above are the instructions I need and below is what I currently have. #include #include // global constants a.k.a. macros #define NAME 20 #define YELLOW 1 #define RED 2 #define ZERO 0 #define FOUR 4 // function prototypes void welcomeScreen (); void displayEmptyBoard(); void playGame(); // main function int main()
  • 4. { // call function welcomeScreen welcomeScreen(); // call function displayEmptyBoard // displayEmptyBoard(); // call function playGame playGame(); // program executed successfully return 0; } // welcomeScreen function displays the Connect Four logo and rules of the game void welcomeScreen () { printf (" CCCC OOOO N N N N EEEEE CCCC TTTTT FFFFF OOOO U U RRRR n"); printf ("C O O N N N N N N EE C T F O O U U R R n"); printf ("C O O N N N N N N EEEE C T FFF O O U U R R n"); printf ("C O O N NN N NN EE C T F O O U U R R n"); printf (" CCCC OOOO N N N N EEEEE CCCC T F OOOO UUUU R R n"); printf ("n"); printf ("CONNECT FOUR GAME RULESnn"); printf("t 1. The board is 6 rows and 7 columns.n"); printf("t 2. The player with the yellow discs goes first.n"); printf("t 3. Players drop 1 disc in the grid at a time.n"); printf("t 4. Players alternate turns.n"); printf("t 5. Once a player has four discs in a row vertically, horizontally or diagonally, they have won the game!n"); } // function displayEmptyBoard displays a hardcoded version of an Connect Four board void displayEmptyBoard() { printf("|------------------------------------------n");
  • 5. printf("| A | B | C | D | E | F | G |n"); printf("|------------------------------------------n"); printf("|------------------------------------------n"); printf("| | | | | | | |n"); printf("|------------------------------------------n"); printf("| | | | | | | |n"); printf("|------------------------------------------n"); printf("| | | | | | | |n"); printf("|------------------------------------------n"); printf("| | | | | | | |n"); printf("|------------------------------------------n"); printf("| | | | | | | |n"); printf("|------------------------------------------n"); printf("| | | | | | | |n"); printf("|------------------------------------------n"); } void playGame() { // store player names char yellow[NAME]; // Karin char red[NAME]; // Lia // yellow (Y) always goes first int currentPlayer = YELLOW; int loop = ZERO; printf("Player Yellow, please enter your namen"); scanf("%s", yellow); printf("Player Red, please enter your namen"); scanf("%s", red); printf("%s and %s, let's play Connect Four!n", yellow, red); while(loop < FOUR) { // call function displayEmptyBoard displayEmptyBoard(); // switch players for each move if(currentPlayer == YELLOW) {
  • 6. printf("%s, it is your turnn", yellow); // switch players currentPlayer = RED; } else if(currentPlayer == RED) { printf("%s, it is your turnn", red); currentPlayer = YELLOW; } loop++; } } Please provide code screenshots in C language. Thank you