Question

Can someone tell me why this is not printing in the screen. I know i commented...

Can someone tell me why this is not printing in the screen. I know i commented out the first couple functions but the last one is not working.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ROWS 5
#define COLS 5
#define FREE 2
#define SCALE 15
#define SHIFT 1
#define MAXVAL 75
#define FALSE 0
#define TRUE 1
void welcomeScreen();
void clearScreen();
void displayExplicitCard();
void displayCard();
void displayRandomCard();
void fillCardRand();
void setValue();
void displayBingoCard();
void initializeArrays ();


int main (int used[MAXVAL])
{
int card[ROWS][COLS];
srand(time(0));
welcomeScreen();
clearScreen();
// displayExplicitCard();
//clearScreen();
//displayCard();
//clearScreen();
//displayRandomCard();
//clearScreen();
initializeArrays(used);
fillCardRand(card,used);
displayBingoCard(card);

return 0;
}

void welcomeScreen()
{

printf(" Welcome to Bingo!\n");
// Rules of the game//
printf("Rules of the game:\n");
printf("1. A player recieves a Bingo card\n");
printf("2. Each card has a random placement of numbers for each column, B, I, N, G, O\n");
printf(" Colum B contains values 1 - 15\n");
printf(" Colum I contains values 16 - 30\n");
printf(" Colum N contains values 31 - 45 in addition to a FREE space\n");
printf(" Colum G contains values 46 - 60\n");
printf(" Colum O contains values 61 - 75\n");
printf("3. Various patterns are identified to accomplish a BINGO\n");
printf("4. Each round of the game will identify which patern should be accomplished to win BINGO\n");
printf("5. Winning numbers are randomly slected during play\n6. Good luck!\n\n");

}

void clearScreen ()
{
printf(" Hit <ENTER> to beggin\n\n");
char enter;
scanf("%c" , &enter);
system("cls");
// system("clear");//

}

void displayExplicitCard ()
{
printf("Function displayExplicitCard\n");
printf("|----------------------------------|\n");
printf("| B | I | N | G | O |\n");
printf("|----------------------------------|\n");
printf("| 15 | 16 | 31 | 46 | 61 |\n");
printf("|----------------------------------|\n");
printf("| 2 | 23 | 45 | 60 | 75 |\n");
printf("|----------------------------------|\n");
printf("| 5 | 20 | FREE | 51 | 68 |\n");
printf("|----------------------------------|\n");
printf("| 12 | 27 | 40 | 50 | 70 |\n");
printf("|----------------------------------|\n");
printf("| 9 | 30 | 37 | 49 | 64 |\n");
printf("|----------------------------------|\n");

}
void displayCard ()
{
printf("Function displayCard\n");
int row;
int col;
int num;
printf("|---------------------------------------|\n");
printf("| B | I | N | G | O |\n");
printf("|---------------------------------------|\n");
for(row = 0; row < ROWS; row++)
{ printf("|");
for(col = 0; col < COLS; col++)
{
num = (col + SHIFT) * SCALE - row;
if(row == FREE && col == FREE)
{printf(" FREE |");}
else
{ printf("%s%-3d", " ", num);
printf(" |"); }
}
printf("\n");
printf("|---------------------------------------|\n"); }
}


void displayRandomCard()
{
printf("Function displayRandomCard\n");
int row,col,num,base;
printf("|---------------------------------------|\n");
printf("| B | I | N | G | O |\n");
printf("|---------------------------------------|\n");
for(row = 0; row < ROWS; row++){
printf("|");
for(col = 0; col < COLS; col++){
base=(col)*SCALE;
num=rand()%15+base+1;
if(row==FREE&&col==FREE){printf(" FREE |");}
else
{
printf("%s%-3d"," ",num);
printf(" |");}
}
printf("\n");
printf("|---------------------------------------|\n");
}


}
void fillCardRand(int card[ROWS][COLS],int num, int used[MAXVAL])
{
int row,col;
for(row = 0; row < ROWS; row++)
{
for(col = 0; col < COLS; col++){
if(row==FREE&&col==FREE){card[FREE][FREE]=0;}
else {
setValue(card,row,col);
}
}
}
}
void setValue(int card[5][5],int row,int col,int used[MAXVAL])
{
int num,base,idx;
base=col*SCALE;
num=(rand()%SCALE)+base+1;
card[row][col]=num;
idx=num-SHIFT;
if(used[idx]==FALSE){
used[idx]=TRUE;
card[row][col]=num;
}
else setValue(card,row,col,used);
}

void displayBingoCard(int card[ROWS][COLS])
{
int row,col;
printf("Function displayBingoCard\n");
printf("|---------------------------------------|\n");
printf("| B | I | N | G | O |\n");
printf("|---------------------------------------|\n");
for(row = 0; row < ROWS; row++)
{
printf("|");
for(col = 0; col < COLS; col++){
if(row==FREE&&col==FREE){printf(" FREE |");}


else {
printf("%s%-3d" ," " ,card[row][col] );
printf(" |");
}} printf("\n");
printf("|---------------------------------------|\n");
}}

void initializeArrays (int used[MAXVAL])
{
int col;
for (int col = 0;col<MAXVAL;col++)

{
used[MAXVAL]=FALSE;
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*

Your program is not printing because there are four errors in your program. But remember i have only checked the part of the code which is being executed and i have not checked the functions which has been commented out. I am listing out the errors along with the line no. below -

1. Line No. 23 - You cannot declare an integer array as an argument of main function. You need to declare it inside the main function or outside if you want to use it as global.

2. Line no. 138 - You have passed only 2 arguments to the function 'fillCardRand' which accepts 3 arguments. However there is no need of the variable 'num' that you have used as an argument while defining the function 'fillCardRand' as you have not used the variable inside the function. So i have removed it while correcting the code.

3. Line no. 146 - You have passed only 3 arguments to the function 'setValue' which accepts 4 arguments. You forgot to pass the array 'used' to the function 'setValue'.

4. Line no. 192 - You have only initialized the last element of the array 'used' to FALSE. By mistake you wrote 'used[MAXVAL] = FALSE' instead of 'used[col] = FALSE' inside the loop.

Below is the corrected code.

*/

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#define ROWS 5

#define COLS 5

#define FREE 2

#define SCALE 15

#define SHIFT 1

#define MAXVAL 75

#define FALSE 0

#define TRUE 1

void welcomeScreen();

void clearScreen();

void displayExplicitCard();

void displayCard();

void displayRandomCard();

void fillCardRand();

void setValue();

void displayBingoCard();

void initializeArrays ();


int main ()

{

int used[MAXVAL];

int card[ROWS][COLS];

srand(time(0));

welcomeScreen();

clearScreen();

// displayExplicitCard();

//clearScreen();

//displayCard();

//clearScreen();

//displayRandomCard();

//clearScreen();

initializeArrays(used);

fillCardRand(card,used);

displayBingoCard(card);

return 0;

}

void welcomeScreen()

{

printf(" Welcome to Bingo!\n");

// Rules of the game//

printf("Rules of the game:\n");

printf("1. A player recieves a Bingo card\n");

printf("2. Each card has a random placement of numbers for each column, B, I, N, G, O\n");

printf(" Colum B contains values 1 - 15\n");

printf(" Colum I contains values 16 - 30\n");

printf(" Colum N contains values 31 - 45 in addition to a FREE space\n");

printf(" Colum G contains values 46 - 60\n");

printf(" Colum O contains values 61 - 75\n");

printf("3. Various patterns are identified to accomplish a BINGO\n");

printf("4. Each round of the game will identify which patern should be accomplished to win BINGO\n");

printf("5. Winning numbers are randomly slected during play\n6. Good luck!\n\n");

}

void clearScreen ()

{

printf(" Hit <ENTER> to beggin\n\n");

char enter;

scanf("%c" , &enter);

system("cls");

// system("clear");//

}

void displayExplicitCard ()

{

printf("Function displayExplicitCard\n");

printf("|----------------------------------|\n");

printf("| B | I | N | G | O |\n");

printf("|----------------------------------|\n");

printf("| 15 | 16 | 31 | 46 | 61 |\n");

printf("|----------------------------------|\n");

printf("| 2 | 23 | 45 | 60 | 75 |\n");

printf("|----------------------------------|\n");

printf("| 5 | 20 | FREE | 51 | 68 |\n");

printf("|----------------------------------|\n");

printf("| 12 | 27 | 40 | 50 | 70 |\n");

printf("|----------------------------------|\n");

printf("| 9 | 30 | 37 | 49 | 64 |\n");

printf("|----------------------------------|\n");

}

void displayCard ()

{

printf("Function displayCard\n");

int row;

int col;

int num;

printf("|---------------------------------------|\n");

printf("| B | I | N | G | O |\n");

printf("|---------------------------------------|\n");

for(row = 0; row < ROWS; row++)

{ printf("|");

for(col = 0; col < COLS; col++)

{

num = (col + SHIFT) * SCALE - row;

if(row == FREE && col == FREE)

{printf(" FREE |");}

else

{ printf("%s%-3d", " ", num);

printf(" |"); }

}

printf("\n");

printf("|---------------------------------------|\n"); }

}


void displayRandomCard()

{

printf("Function displayRandomCard\n");

int row,col,num,base;

printf("|---------------------------------------|\n");

printf("| B | I | N | G | O |\n");

printf("|---------------------------------------|\n");

for(row = 0; row < ROWS; row++){

printf("|");

for(col = 0; col < COLS; col++){

base=(col)*SCALE;

num=rand()%15+base+1;

if(row==FREE&&col==FREE){printf(" FREE |");}

else

{

printf("%s%-3d"," ",num);

printf(" |");}

}

printf("\n");

printf("|---------------------------------------|\n");

}


}

void fillCardRand(int card[ROWS][COLS], int used[MAXVAL])

{

int row,col;

for(row = 0; row < ROWS; row++)

{

for(col = 0; col < COLS; col++){

if(row==FREE&&col==FREE){card[FREE][FREE]=0;}

else {

setValue(card,row,col,used);

}

}

}

}

void setValue(int card[5][5],int row,int col,int used[MAXVAL])

{

int num,base,idx;

base=col*SCALE;

num=(rand()%SCALE)+base+1;

card[row][col]=num;

idx=num-SHIFT;

if(used[idx]==FALSE){

used[idx]=TRUE;

card[row][col]=num;

}

else setValue(card,row,col,used);

}

void displayBingoCard(int card[ROWS][COLS])

{

int row,col;

printf("Function displayBingoCard\n");

printf("|---------------------------------------|\n");

printf("| B | I | N | G | O |\n");

printf("|---------------------------------------|\n");

for(row = 0; row < ROWS; row++)

{

printf("|");

for(col = 0; col < COLS; col++){

if(row==FREE&&col==FREE){printf(" FREE |");}


else {

printf("%s%-3d" ," " ,card[row][col] );

printf(" |");

}} printf("\n");

printf("|---------------------------------------|\n");

}}

void initializeArrays (int used[MAXVAL])

{

int col;

for (int col = 0;col<MAXVAL;col++)

{

used[col]=FALSE;

}

}

// End of the Program.

Add a comment
Know the answer?
Add Answer to:
Can someone tell me why this is not printing in the screen. I know i commented...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need a basic program in C to modify my program with the following instructions: Create...

    I need a basic program in C to modify my program with the following instructions: Create a program in C that will: Add an option 4 to your menu for "Play Bingo" -read in a bingo call (e,g, B6, I17, G57, G65) -checks to see if the bingo call read in is valid (i.e., G65 is not valid) -marks all the boards that have the bingo call -checks to see if there is a winner, for our purposes winning means...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • When outputting the path found in the proposed program, the direction of movement is output. Howe...

    When outputting the path found in the proposed program, the direction of movement is output. However, the direction of movement to the last movement, EXIT, is not output. To print this out, please describe how to modify the proposed program. #include <stdio.h> #define NUM_ROWS 5 #define NUM_COLS 3 #define BOUNDARY_COLS 5 #define MAX_STACK_SIZE 100 #define FALSE 0 #define TRUE 1 ​ ​ ​ typedef struct { short int row; short int col; short int dir; } element; ​ element stack[MAX_STACK_SIZE];...

  • Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...

    Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS: Here is my code I have that needs to be edited with instructions. : void displayUpperSection(int scoreCard[CATEGORIES][COLS]){ printf("+-----------------|-----------|\n"); printf("+ UPPER SECTION | SCORE |\n"); printf("+-----------------|-----------|\n"); printf("+ ONEs | %d |\n", scoreCard[one][COL]); printf("+-----------------|-----------|\n"); printf("+ TWOS | %d |\n", scoreCard[two][COL]); printf("+-----------------|-----------|\n"); printf("+ THREES | %d |\n", scoreCard[three][COL]); printf("+-----------------|-----------|\n"); printf("+ FOURS | %d |\n", scoreCard[four][COL]); printf("+-----------------|-----------|\n"); printf("+ FIVES | %d |\n", scoreCard[five][COL]); printf("+-----------------|-----------|\n"); printf("+ SIXES | %d...

  • Please do in C please. Edit sliding.c. Comments on code would be nice. Thank you. Here is main.c #include "sliding.h" #include <malloc.h> #include <stdlib.h> //Prints grid in row...

    Please do in C please. Edit sliding.c. Comments on code would be nice. Thank you. Here is main.c #include "sliding.h" #include <malloc.h> #include <stdlib.h> //Prints grid in row major order. Tries to ensure even spacing. void print_grid(int * my_array, int rows, int cols){ int i,j; for(i=0; i<rows; i++){ for(j=0; j<cols; j++){ if(my_array[i*cols + j]!=-1){ printf(" %d ", my_array[i*cols + j]); } else{ printf("%d ", my_array[i*cols + j]); } } printf("\n"); } } int main(int argc, char *argv[]) { int seed,rows,cols;...

  • C++ there is an issue with my if/else statements, I have tried several different ways to...

    C++ there is an issue with my if/else statements, I have tried several different ways to make it match the instructions but each time i get different errors. Need help geting this to match the instructions peoperly. *******************instructions***************************** Function: nextGeneration This function has no parameters. This function returns an int. The purpose of this function is to modify the grid to represent the next generation. Here's how you are supposed to do that for this assignment: Set each element of...

  • I need help with the following and written in c++ thank you!: 1) replace the 2D...

    I need help with the following and written in c++ thank you!: 1) replace the 2D arrays with vectors 2) add a constructor to the Sudoku class that reads the initial configuration from a file 3) adds a function to the Sudoku class that writes the final Sudoku grid to a file or to the standard output device, cout. Sudoku.h #pragma once /* notes sudoku() default constructor precondition : none postcondition: grid is initialized to 0 sudoku(g[][9]) 1-parameter constructor precondition...

  • I need help modifying this program. How would I make sure that the methods is being...

    I need help modifying this program. How would I make sure that the methods is being called and checked in my main method? Here is what the program needs to run as: GDVEGTA GVCEKST The LCS has length 4 The LCS is GVET This is the error that I'm getting: The LCS has length 4 // I got this right The LCS is   //the backtrace is not being called for some reason c++ code: the cpp class: /** * calculate...

  • #include <stdio.h> #include <stdlib.h> #include <string.h> struct game_piece { ...

    #include <stdio.h> #include <stdlib.h> #include <string.h> struct game_piece { }; struct game_board { }; void game_piece_init_default(struct game_piece* piece) { } void game_piece_init(struct game_piece* piece, char* new_label) { } char* game_piece_get_label(struct game_piece* piece) { return ""; } char* game_piece_to_string(struct game_piece* piece) { return ""; } void game_board_init(struct game_board* game_board, int rows, int cols) { } int game_board_is_space_valid(struct game_board* game_board, int row, int col) { return 0; } int game_board_add_piece(struct game_board* game_board, struct game_piece* piece, int row, int col) { return 0;...

  • The objective is to use each row of the first column as a starting point to...

    The objective is to use each row of the first column as a starting point to come up with a sum of absolute value of differences . For each row, a sum will be calculated, therefore, 5 sums must be calculated. Each sum will be placed into the array, sumList[ ]. #include <stdio.h> #include <stdlib.h> #include <math.h> #define ROWS 5 #define COLS 6 void calcSums(int topog[ROWS][COLS], int sumList[ROWS] ); int main() { int topography[ROWS][COLS] = { { 3011, 2800, 2852,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT