include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
1. #include <stdio.h>
#include <stdlib.h>
#include <time.h>
void FillBingoCard(int bingocard[5][5]);
void PrintCard(int bingocard[5][5], int called[3], char yn[1]);
int PickNumber(int called[3], int callednumber[75], int counter);
int drawnnumber(int bingocard[5][5], int called[3]);
void completedrowcolumn(int bingocard[5][5], int win);
int main(void)
{
//array of bingo numbers
int row = 5;
int col = 5;
int bingocard[row][col];
int called[3];
int counter = 0;
int callednumber[75];
char yn[1];
int win = 0;
//fill bingocard
void FillBingoCard(int bingocard[5][5])
{
int i, j, k;
int temp;
srand(time(NULL));
for (i = 0; i < 5; i++)
{
for (j = 0; j < 5; j++)
{
temp = rand() % 15 + 1 + j * 15;
for (k = 0; k < j; k++)
{
if (temp == bingocard[i][k])
{
j--;
break;
}
}
2. bingocard[i][j] = temp;
}
}
bingocard[2][2] = -1;
}
void PrintCard(int bingocard[5][5], int called[3], char yn[1])
{
int i, j;
printf(" B I N G On");
for (i = 0; i < 5; i++)
{
printf("----------------------n");
for (j = 0; j < 5; j++)
{
if (bingocard[i][j] == -1)
{
printf("| X ");
}
else if (called[0] == 'B' && called[1] == bingocard[i][j])
{
printf("| %2d", bingocard[i][j]);
}
else if (called[0] == 'I' && called[1] == bingocard[i][j])
{
printf("| %2d", bingocard[i][j]);
}
else if (called[0] == 'N' && called[1] == bingocard[i][j])
{
printf("| %2d", bingocard[i][j]);
}
else if (called[0] == 'G' && called[1] == bingocard[i][j])
{
printf("| %2d", bingocard[i][j]);
}
else if (called[0] == 'O' && called[1] == bingocard[i][j])
{
printf("| %2d", bingocard[i][j]);
}
else
{
printf("| %2d", bingocard[i][j]);
3. }
}
printf("|n");
}
printf("----------------------n");
printf("Have you got number %c%d? (Y/N) ", called[0], called[1]);
scanf(" %c", yn);
}
int PickNumber(int called[3], int callednumber[75], int counter)
{
int temp;
srand(time(NULL));
do
{
temp = rand() % 75 + 1;
} while (callednumber[temp - 1] != 0);
callednumber[temp - 1] = 1;
called[1] = temp;
if (temp <= 15)
{
called[0] = 'B';
}
else if (temp <= 30)
{
called[0] = 'I';
}
else if (temp <= 45)
{
called[0] = 'N';
}
else if (temp <= 60)
{
called[0] = 'G';
}
else
{
called[0] = 'O';
}
return *called;
4. }
int drawnnumber(int bingocard[5][5], int called[3])
{
int row, col;
int found = 0;
for (row = 0; row < 5; row++)
{
for (col = 0; col < 5; col++)
{
if (bingocard[row][col] == called[1])
{
bingocard[row][col] = -1;
found = 1;
}
}
}
if (found == 1)
{
return 1;
}
else
{
return 0;
}
}
{
int row, col;
// check for completed rows
for (row = 0; row < 5; row++)
{
int count = 0;
for (col = 0; col < 5; col++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
5. printf("nBINGO! You completed row %d.", row + 1);
win = 1;
}
}
// check for completed columns
for (col = 0; col < 5; col++)
{
int count = 0;
for (row = 0; row < 5; row++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed column %d.", col + 1);
win = 1;
}
}
}
void completedrowcolumn(int bingocard[5][5], int win)
{
int row, col, diag, count;
// check for completed rows
for (row = 0; row < 5; row++)
{
count = 0;
for (col = 0; col < 5; col++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed row %d.", row + 1);
win = 1;
}
6. }
// check for completed columns
for (col = 0; col < 5; col++)
{
count = 0;
for (row = 0; row < 5; row++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed column %d.", col + 1);
win = 1;
}
}
// check for completed diagonal lines
count = 0;
for (diag = 0; diag < 5; diag++)
{
if (bingocard[diag][diag] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed the diagonal line from top left to bottom right.");
win = 1;
}
count = 0;
for (diag = 0; diag < 5; diag++)
{
if (bingocard[diag][4 - diag] == -1)
{
count++;
}
}
7. if (count == 5)
{
printf("nBINGO! You completed the diagonal line from top right to bottom left.");
win = 1;
}
if (win == 1)
{
printf("nCongratulations! You won!");
}
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void FillBingoCard(int bingocard[5][5]);
void PrintCard(int bingocard[5][5], int called[3], char yn[1]);
int PickNumber(int called[3], int callednumber[75], int counter);
int drawnnumber(int bingocard[5][5], int called[3]);
void completedrowcolumn(int bingocard[5][5], int win);
int main(void)
{
//array of bingo numbers
int row = 5;
int col = 5;
int bingocard[row][col];
int called[3];
8. int counter = 0;
int callednumber[75];
char yn[1];
int win = 0;
//fill bingocard
void FillBingoCard(int bingocard[5][5])
{
int i, j, k;
int temp;
srand(time(NULL));
for (i = 0; i < 5; i++)
{
for (j = 0; j < 5; j++)
{
temp = rand() % 15 + 1 + j * 15;
for (k = 0; k < j; k++)
{
if (temp == bingocard[i][k])
{
j--;
9. break;
}
}
bingocard[i][j] = temp;
}
}
bingocard[2][2] = -1;
}
void PrintCard(int bingocard[5][5], int called[3], char yn[1])
{
int i, j;
printf(" B I N G On");
for (i = 0; i < 5; i++)
{
printf("----------------------n");
for (j = 0; j < 5; j++)
{
if (bingocard[i][j] == -1)
{
printf("| X ");
}
13. }
int drawnnumber(int bingocard[5][5], int called[3])
{
int row, col;
int found = 0;
for (row = 0; row < 5; row++)
{
for (col = 0; col < 5; col++)
{
if (bingocard[row][col] == called[1])
{
bingocard[row][col] = -1;
found = 1;
}
}
}
if (found == 1)
{
return 1;
}
14. else
{
return 0;
}
}
{
int row, col;
// check for completed rows
for (row = 0; row < 5; row++)
{
int count = 0;
for (col = 0; col < 5; col++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed row %d.", row + 1);
15. win = 1;
}
}
// check for completed columns
for (col = 0; col < 5; col++)
{
int count = 0;
for (row = 0; row < 5; row++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed column %d.", col + 1);
win = 1;
}
}
16. }
void completedrowcolumn(int bingocard[5][5], int win)
{
int row, col, diag, count;
// check for completed rows
for (row = 0; row < 5; row++)
{
count = 0;
for (col = 0; col < 5; col++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed row %d.", row + 1);
win = 1;
}
}
17. // check for completed columns
for (col = 0; col < 5; col++)
{
count = 0;
for (row = 0; row < 5; row++)
{
if (bingocard[row][col] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed column %d.", col + 1);
win = 1;
}
}
// check for completed diagonal lines
count = 0;
for (diag = 0; diag < 5; diag++)
18. {
if (bingocard[diag][diag] == -1)
{
count++;
}
}
if (count == 5)
{
printf("nBINGO! You completed the diagonal line from top left to bottom right.");
win = 1;
}
count = 0;
for (diag = 0; diag < 5; diag++)
{
if (bingocard[diag][4 - diag] == -1)
{
count++;
}
}
if (count == 5)
{
19. printf("nBINGO! You completed the diagonal line from top right to bottom left.");
win = 1;
}
if (win == 1)
{
printf("nCongratulations! You won!");
}
}
* It should also include the lines, and mark any called numbers with 'X'. If a number called isn't on
my card and I indicate 'Y' that yes, I do have it, it should print me a message saying that I cheated
and end the game. It should be in C. If you help, please send a working code so that I can check
with mine!
The next number is 065 Do you have it? (Y/N)Y That value is not on your BINGo card - are you
trying to cheat??For filling the card with unique numbers, you have to go through the BINGO card
column by column (rather than row by row which is what we normally do for 2D arrays). Since the
BINGO card has 5 columns, this would be a good place to use a for loop. Now, for each column
(inside the for loop), you need to find 5 unique values that fit within the allowed range for that
column. So, WHILE you haven't found all 5, get a random number in range, check if you have
already gotten it in that column - if you have, throw it out and get another - if you haven't, put it in
your BINGO card. So for the Oth column, your number needs to be 1-15 1st column, your number
needs to be 1630 2nd column, your number needs to be 31-45 3 rd column, your number needs to
be 46-60 4th column, your number needs to be 61-75Create a function to print the bingo card to
the screen. You must match the formatting shown in the sample output. The bingo array must be
passed to this function. Create a function to pick a number that has not already been chosen. You
will need to use a 10 array to keep track of which numbers between 1 and 75 have been used so
that you don't pick numbers that have already been called. If you randomly pick a number that was
already called, then pick another. Continue this process until you find a number that has not been
previously called. Print the number to the screen along with its corresponding letter. This function
should return that value. Do NOT create an array of 75 unique numbers - pick one number at a
time and ensure it has not already been used. Create a function to determine if a called number
exists in the player's bingo card. Pass the bingo array and the number to the function. Loop over
the array (nested for loops) and, if the number is found in the bingo array, then change the value
20. to 0 to "mark" it. If the number is found, then this function should return true; otherwise, return
false. PLEASE REMEMBER THAT YOU ARE NOT ALLOWED TO USE re turn TO STOP A
LOOP. Create a function to check for a completed row. A completed row is a row in the bingo
array that has 0 for every value (we "marked" our bingo numbers by changing the existing value to
zero to indicate that the called number matches one in our bingo card). This function should check
every row in the bingo array and return whether or not it found a completed row. Create a function
to check for a completed column. A completed column is a column in the bingo array that has 0 for
every value (we "marked" our bingo numbers by changing the existing value to zero to indicate
that the called number matches one in our bingo card). This function should check every column in
the bingo array and return whether or not it found a completed column. Create a function to check
for a completed diagonal. A completed diagonal is a diagonal in the bingo array that has 0 for
every value (we "marked" our bingo numbers by changing the existing value to zero to indicate
that the called number matches one in our bingo card). This function should check both diagonals
in the bingo array and return whether or not it found a completed diagonal. Add prototypes for the
functions at the top of the program. main() Call function to fill bingo card Call function to print bingo
card to screen While the player has not won and while there are still numbers to choose from
(there are 75 total) Call a function to pick a number that has not been chosen already - this
function returns the called number. Show the player the number (including the B, I, N, G or O ) and
ask if the player has that number on their bingo card. If the player answers anything other than
something that begins with ' ', then reprint the bingo card and increment the count of numbers
drawn so far. / N NOTE : Your code must use this prompt so that your code can easily be tested %
Create a 2D array that will be your bingo card. The bingo card will ONLY be 55. Make sure your
random numbers are truly random between program runs. Use srand () only once and not in a
function or loop. Create a function to fill the bingo card with random numbers in the proper ranges.
Pass your 2D bingo array to this function to be populated. Be sure to mark the free spot. The ' B '
column contains numbers between 1 and 15 The 'I' column contains numbers between 16 and 30
not hardcode any of the numbers in The ' N ' column contains numbers between 31 and 45 your
BINGO card - every number The ' G ' column contains numbers between 46 and 60 should
random and in the correct range. The ' O column contains numbers between 61 and 75 Just a
reminder - BINGO numbers MUST be unique. You cannot have the same number in multiple cells
of your BINGO card. The rules of BINGO state that every number is unique. Obtaining random
numbers using rand () does NOT guarantee that each number is unique - YOU must check that
each number is unique. If a number has already been used, then get another number. Use the
formula we went over in class to obtain numbers in a range do not hardcode every range.Create a
function to print the bingo card to the screen. You must match the formatting shown in the sample
output. The bingo array must be passed to this function. Create a function to pick a number that
has not already been chosen. You will need to use a 10 array to keep track of which numbers
between 1 and 75 have been used so that you don't pick numbers that have already been called.
If you randomly pick a number that was already called, then pick another. Continue this process
until you find a number that has not been previously called. Print the number to the screen along
with its corresponding letter. This function should return that value. Do NOT create an array of 75
unique numbers - pick one number at a time and ensure it has not already been used. Create a
21. function to determine if a called number exists in the player's bingo card. Pass the bingo array and
the number to the function. Loop over the array (nested for loops) and, if the number is found in
the bingo array, then change the value to 0 to "mark" it. If the number is found, then this function
should return true; otherwise, return false. PLEASE REMEMBER THAT YOU ARE NOT
ALLOWED TO USE IE tUEN TO STOP A LOOP. Create a function to check for a completed row.
A completed row is a row in the bingo array that has 0 for every value (we "marked" our bingo
numbers by changing the existing value to zero to indicate that the called number matches one in
our bingo card). This function should check every row in the bingo array and return whether or not
it found a completed row. Create a function to check for a completed column. A completed column
is a column in the bingo array that has 0 for every value (we "marked" our bingo numbers by
changing the existing value to zero to indicate that the called number matches one in our bingo
card). This function should check every column in the bingo array and return whether or not it
found a completed column. Create a function to check for a completed diagonal. A completed
diagonal is a diagonal in the bingo array that has 0 for every value (we "marked" our bingo
numbers by changing the existing value to zero to indicate that the called number matches one in
our bingo card). This function should check both diagonals in the bingo array and return whether
or not it found a completed diagonal. Add prototypes for the functions at the top of the program.
masin( Call function to fill bingo card Call function to print bingo card to screen While the player
has not won and while there are still numbers to choose from (there are 75 totall) Call a function to
pick a number that has not been chosen already-this function returns the called number. Show the
player the number (including the B,I,N,G or O ) and ask if the player has that number on their
bingo card. If the player answers anything other than something that begins with ' Y ', then reprint
the bingo card and increment the count of numbers drawn so far. I NOTE ; Your code must use
this prompt so that your code can easily be tested * / If the player answers something that begins
with , then Call a function to determine if the number drawn IS a number from the bingo card.