Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C ONLY PLEASE: Write a program that will prompt the user for the number of players (maximum of 5) prompt the user for the

IN C ONLY PLEASE: Write a program that will prompt the user for the number of players (maximum of 5) prompt the user for the number of cards to generate for each player (maximum of 10) for each card for each player, generate a valid bingo card (5 columns and 5 rows, here are some images of bingo cards provide a menu for the user to select which user/bingo card to display to run a histogram on the bingo cards generated to see how many times each number between 1 and 75 appeared. This is my code an it seems to work, but how do i input the "Free" space in the middle of the bingo board?

#include #include #include

int get_random_number(int min, int max) { return min + (rand() % (max - min + 1)); } int min_for_col(int column_index) { return (column_index * 15) + 1; } int max_for_col(int column_index) { return (column_index + 1) * 15; } void print_bingo_card(int cards[5][10][5][5], int player, int card) {int i, j; printf("B I N G O "); for(i = 0; i < 5; ++i) { for(j = 0; j < 5; ++j) { if(i == 2 && j ==2) { printf(" "); } else{ printf("%2d ", cards[player][card][i][j]); } } printf(" "); } printf(" "); }

int main () { srand(time(NULL)); int num_players, num_cards, i, j, k, l, m, num; int bingo_cards[5][10][5][5]; int count[75]; int num_rows = 5, num_cols = 5; int already_exists = 0; printf("Enter number of players:"); //asking for player count scanf("%d", &num_players);//scanning user input printf("Enter number of cards per players:");//Asking for number of cards per person. scanf("%d", &num_cards);//scanning user input for(i = 0; i < num_players; ++i){ for(j = 0; j < num_cards; ++j){ for (k = 0; k < num_cols; ++k) { for(l = 0; l < num_rows; ++l){ while(1) { num = get_random_number(min_for_col(k), max_for_col(k)); already_exists = 0; for(m = 0; m < 1; ++m){ if(bingo_cards[i][j][m][k] == num){ already_exists = 1; } } if(already_exists == 0){ break; } } bingo_cards[i][j][l][k] = num; } } } } //histogram calculations for( i = 0; i < 75; ++i){ count[i] = 0; } for(i = 0; i < num_players; ++i){ for(j = 0; j < num_cards; ++j){ for (k = 0; k

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

Explain the term just cause.

Answered: 1 week ago

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

What is meant by Career Planning and development ?

Answered: 1 week ago