Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the following code in c language : Connect four is a two-player board game in which the players alternately drop colored disks into a

write the following code in c language :

Connect four is a two-player board game in which the players alternately drop colored disks into a seven-column, six-row vertically suspended grid, as shown below The objective of the game is to connect four same-colored disks in a row, or a column before your opponent can do likewise. Inside your folder, create a project named finalQ. Use this project to write and run a C program that repeatedly performs the following: Create a 2D array of character to store the game board Create a function named initBoard that takes as an argument at least a 7-coloumn 2D array of characters and initializes the array with a space Create a function named printBoard that takes as an argument at least a 7-coloumn 2D array of characters and properly print the board (as in the sample sun) Create a function named checkHorizontalWin that takes as an argument at least a 7-coloumn 2D array of characters, row index (r), and a character representing the color of a particle player (p). The function should return 1 if the player (p) has four consecutive () disks in row index r, and 0 otherwise Create a function named checkVericalWin that takes as an argument at least a 7-coloumn 2D array of characters, a column index (c), and a character representing the color of a particle player (p). The function should return 1 if the player (p) has four consecutive () disks in column index c, and 0 otherwise Create a function named checkDraw that takes as an argument at least a 7-coloumn 2D array of characters, and return 1 if the result of the game draw () and 0 otherwise Repeatedly prompts two players to drop a RED or YELLOW disk alternately. Whenever a disk is dropped, the program redisplays the board on the screen and determines the player wins, or if it is a draw, or continue. Here is a sample run (on the next page) | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ---------------------- Drop a red disk at column (06): 0 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |R| | | | | | | ---------------------- Drop a yellow disk at column (06): 3 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |R| | |Y| | | | ---------------------- ... ... ... Drop a yellow disk at column (06): 6 | | | | | | | | | | | | | | | | | | | |R| | | | | | | |Y|R|Y| | | | |R|Y|Y|Y|Y| |R|Y|R|Y|R|R|R| ---------------------- The yellow player won

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

Provide an IUPAC name for the compound below.

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago