In C coding language please.
this is what i have so far
#include <stdio.h>
#include <stdlib.h>
// constants
#define ROWS 4
#define COLS 4
#define LETTERS 26
// function prototypes
void welcomeScreen ();
void displayExplicitBoard();
void clearScreen();
void displayBoard();
// main function
int main()
{
// call function welcomeScreen
welcomeScreen();
// call function clearScreen
clearScreen();
// call function displayExplicitBoard
displayExplicitBoard();
// call function clearScreen
clearScreen();
// call function displayCard()
displayBoard();
// program executed successfully
return 0;
}
// welcomeScreen function displays the BINGO logo and rules ofthe game
void welcomeScreen ()
{
printf ("\t\tBBBBB OOOO GGGGG GGGGG LL EEEEEE \n");
printf ("\t\tBB BB OO OO GG GG LL EE \n");
printf ("\t\tBBBBB OO OO GG GG LL EEEE \n");
printf ("\t\tBB BB OO OO GG GGG GG GGG LL EE \n");
printf ("\t\tBBBBB OOOO GGGGGG GGGGGG LLLLLL EEEEEE \n");
printf ("\n\n");//
printf ("RULES OF THE GAME:\n");
printf("\t1. The player is presented with a Boggleboard\n");
printf("\t2. The player will have three minutes tofind as many words as possible.\n");
printf("\t3. Words must contain three letters ormore.\n");
printf("\t4. Words are formed from adjoiningletters.\n");
printf("\t5. Letters must join in the propersequence to spell a word.\n");
printf("\t6. Letters may join horizontally,vertically, or diagonally, to the left, right, up or down.\n");
printf("\t7. No letter cube may be used more thanonce in a single word.\n");
printf("\t8. Words submitted will be scoredaccordingly.\n");
printf("\t9. Good luck!\n");
}
// function displayExplicitBingoCard displays a hardcodedversion of a bingo card
void displayExplicitBoard()
{
printf("|-------------------------------|\n");
printf("| BOGGLEBOARD |\n");
printf("|-------------------------------|\n");
printf("| T | A | O | C |\n");
printf("|-------------------------------|\n");
printf("| L | I | S | M |\n");
printf("|-------------------------------|\n");
printf("| U | N | B | I |\n");
printf("|-------------------------------|\n");
printf("| B | O | G | D |\n");
printf("|-------------------------------|\n");
}
// function clearScreen clears the screen for displaypurposes
void clearScreen()
{
printf("\n\t\t\t\tHit <ENTER> tocontinue!\n");
char enter;
scanf("%c", &enter );
// send the clear screen command Windows
system("cls");
// send the clear screen command for UNIX flavoroperating systems
// system("clear");
}
void displayBoard()
{
int row;
int col;
int num;
char letter;
printf("|-------------------------------|\n");
printf("| BOGGLEBOARD |\n");
printf("|-------------------------------|\n");
for(row = 0; row < ROWS;row++)
{
printf("|");
for(col = 0; col< COLS; col++)
{
// generate the randomnumber
num = rand() %LETTERS;
// convert number tocharacter based on decimal value
letter = 'A' +num;
printf("%s%-3c", " ", letter);
printf(" |");
}
printf("\n");
printf("|--------------------------------\n");
}
}
THANK YOU!!!
+ G Tasks Activity boggle.c 1. Copy the C source code file from Assignment 2 and rename it for Assignment 3 2. Write the preprocessor command to include the time.h header file from the C library 3. Write the preprocessor command to include the string.h header file from the C library 4. After the #include preprocessor commands add the following macros to create constants for the program a. DICE with the value of 16 b. c. d. e. SIDES with the value of 6 TRUE with the value of 1 FALSE with the value of 0 SPACE with the value of '' (i.e. there is ONE explicit space between the open/close '; source code will not compile without the space) 5. 6. Write the function declaration or prototype for function display Dice 7. Write the function declaration or prototype for function createBoard 8. Write the function declaration or prototype for function getLetter Update the function declaration or prototype for function display Board 9. Update the main function to do the following a. At the beginning of the main function, declare the following local variables
i. Two-dimensional array (i.e. dice), data type character, size: 16 rows, 6 columns (i.e. use the constants), initialized to the data in Table 1 Boggle Data ii. Two-dimensional array (i.e. board), data type character, size: 4 rows, 4 columns (i.e. use the constants) iii. One-dimensional array (i.e. usedDie), data type integer, size: 16 columns (i.e. use the constants) b. Call function memset to initialize the used Die array so all elements equal 0, passing the following arguments i. usedDie array d. e. ii. iii. c. Call function memset to initialize the board array so all elements equal an explicit space (i.e. ‘‘), passing the 0 (i.e. use the constants) sizeof(used Die) following arguments i. board array ii. iii. (i.e. use the constants) sizeof(board) Call function srand, pass as an argument function time(0) Comment out or delete the two consecutive functions calls a. display ExplicitBoard(); b. clearScreen(); f. Call function displayDice passing as an argument 2d array dice g. Call function clearScreen h. Call function createBoard, passing as arguments a. 2d array dice b. 2d array board C. ld array usedDie i. Call function displayBoard, passing as an argument 2d array board
10. Update function display Board to do the following a. Update parameter list to include two-dimensional array (i.e. board), data type character, size: 4 rows, 4 columns (i.e. use the constants) b. Comment out or delete local variables i. num ii. letter c. Output to the screen using function printf the first three rows of the boggle board d. Write a for loop to loop through the number of rows (i.e. use constant ROWS) i. Write a for loop to loop through the number of columns (i.e. use constant COLS) 1. Comment out or delete the lines of code that a. // generate the random number b. // convert number to character based on decimal value 2. Output to the console the character stored in the 2d array board the current row/col location 11. Write function display Dice to do the following a. Return type void b. Parameter list includes 4 i. Two-dimensional array (i.e. dice), data type character, size: 16 rows, 6 columns (i.e. use the constants) c. Declare the following local variables i. Data type integer (i.e. row) ii. Data type integer (i.e. col) d. Write a nested for loop to loop through the 2d array dice i. Output to the console the characters stored in the array 12. Write function getLetter to do the following a. Return type char b. Parameter list includes i. Two-dimensional array (i.e. dice), data type character,
G 12. Write function getLetter to do the following a. Return type char b. Parameter list includes i. Two-dimensional array (i.e. dice), data type character, size: 16 rows, 6 columns (i.e. use the constants) ii. Data type integer, (i.e. row) c. Declare the following local variables i. Data type character (i.e. letter) ii. Data type integer (i.e. col) d. Set variable col equal to randomly selecting a value from 0 5 (i.e. use the constants) e. Set variable letter equal to the element in the 2d array dice at the row/col location f. Return variable letter 13. Write function createBoard to do the following a. Return type void b. Parameter list includes ii. i. Two-dimensional array (i.e. dice), data type character, size: 16 rows, 6 columns (i.e. use the constants) Two-dimensional array (i.e. board), data type character, size: 4 rows, 4 columns (i.e. use the constants) iii. One-dimensional array (i.e. usedDie), data type integer, size: 16 columns c. Declare the following local variables i. Data type character (i.e. letter) ii. Data type integer, (i.e. row) iii. Data type integer, (i.e. col) iv. Data type integer (i.e. die) d. Write a loop to loop through the 4 rows (i.e. use the
G Boggle executable Test Case 1 Test Case 2 Test Case 3 Test Case 4 Test Case 5 constants) of the board array i. Initialize variable col to 0 Test Case 1 passes | Test Case 2 passes Test Case 3 passes Test Case 4 passes Test Case 5 passes 1. While variable col is less than 4 (i.e. use the constants) a. Set variable die equal to randomly selecting a value from 0-15 (i.e. use the constants) b. If the die has not been used (i.e. check the used Die array at the location) i. Set variable letter equal to function call getLetter, passing as arguments 1. 2d array dice 2. Local variable die ii. Set array parameter board, at the current row/col location, equal to the value stored in variable letter Source compiles with no warnings Source compiles with no errors Source runs with no errors Source includes comments iii. Set array parameter usedDie, at the current die location, equal to 1 (i.e. use the constants) iv. Increment the loop control variable
In C coding language please. this is what i have so far #include #include // constants #define ROWS
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am