Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

unsing (repl.it) site Exercise 2-Connect four 2D array Exercise Objectives passing 2-D arrays to functions Call by reference Problem Description Connect Four is a two-player

unsing (repl.it) site image text in transcribed
image text in transcribed
Exercise 2-Connect four 2D array Exercise Objectives passing 2-D arrays to functions Call by reference Problem Description 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-column 2D array of characters and initializes the array with space . Create a function named printBoard that takes as an argument at least a 7-column 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-column 2D array of characters, row 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 (y disks in row index r, and otherwise - Create a function named checkVericalWin that takes as an argument at least a 7-column 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 [i] disks in column index c, and otherwise Create a function named checkDraw that takes as an argument at least a 7-column 2D array of characters, and return 1 if the result of the game draw (S) and 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 (0-6): 0 TR] Drop a yellow disk at column (0-6): 3 IRI TYI ... . Drop a yellow disk at column (0-6): 6 JYRYL ! IRIY|YY|Y| IRIYIRIYIRIRIRI 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

Step: 3

blur-text-image

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

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions