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 I get help with adding the following to this code please? 1. When buying multiple...

    Can I get help with adding the following to this code please? 1. When buying multiple tickets, if one of the seats selected is already taken, give a message like "Sorry, one or more of the seats selected is already taken." and prompt the user to select the seats all over. (Or if possible to make it suggest a location where the seats are together that the user can select instead) 2. Print the total cost after all of the...

  • 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;...

  • This program is in C++ which reserves flight seats. It uses a file imported to get...

    This program is in C++ which reserves flight seats. It uses a file imported to get the seat chart called "chartIn.txt" which looks like this 1 A B C D E F 2 A B C D E F It continues until row 10. Sorry unable to provide the chartIn.txt file. I am having issues with function displaySeats, it displays then but when it comes to 10 the row looks like this 1 0 A B C D E ,...

  • I wrote program that have to block all moves for player 1, for game TicTacTOE AI,...

    I wrote program that have to block all moves for player 1, for game TicTacTOE AI, but it is not working. Can someone check what I have not eliminated? #include using namespace std; const int ROWS = 3; const int COLS = 3; int counter = 0; void aITurn(char b[][COLS]); void fillBoard(char board[ROWS][COLS]); void getChoice(char b[][COLS], bool playerToggle); bool gameOver(char b[][COLS]); void showBoard(char board[ROWS][COLS]); int main() {    ///main is complete, nothing to do here    char board[ROWS][COLS];    bool playerToggle =...

  • 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...

  • Can anyone help me to make this program work in C language, this is a blackjack...

    Can anyone help me to make this program work in C language, this is a blackjack game #include #include #include void deal(int, int&) void deal(int, int&, int&) int getbet(int); int main() {    int totdealer, totplayer;    int money, bet, aces;    char yesno = 'Y';    _Bool again;    srand(time(0));    printf("How much money do you have? ");    scanf("%d" , money);    while (money>0 && toupper(yesno) == 'Y')    {        bet = getbet(money);        totdealer...

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