Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x.Hmtly working on a Bingo Game program in C. I have almost finished the program

ID: 3618961 • Letter: X

Question

x.Hmtly working on a Bingo Game program in C. I have almost finished the program and it works fine. I just can't make the functions that show the winning bingo card to work. If anyone can take a look and point me out where I have it wrong so I can fix it. This is the code I have so far:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <conio.h>

#define SIZE 5
#define SIZE_NUM_ARR 76
#define FLUSH while (getchar() != ' ')


void fillCard ( int card[][SIZE] );
int linearSearch ( int card[][SIZE], int col, int target );
void printCard ( int card[][SIZE] );
int playGame ( int card1[][SIZE], int card2[][SIZE], int matches1[][SIZE], int matches2[][SIZE] );
int getNumber ( int chosenNumArray[], int currNum );
void displayNumber ( int currNum );
int checkForMatch ( int card[][SIZE], int matches[][SIZE] );
int checkWinner ( int matches[][SIZE] );
void showWinner ( char nameStr[], int card[][SIZE], int matches[][SIZE] );
int continueFcn ( void );

int main (void)
{
   srand(time(NULL));
   int card1[SIZE][SIZE];
   int card2[SIZE][SIZE];
   int matches1[SIZE][SIZE];
   int matches2[SIZE][SIZE];
   int winner;


   do
   {
    fillCard( card1 );
    fillCard( card2 );
    printf("Your Bingo Card: ");
    printCard( card1 );
    printf(" ");
    printf("Computer's Bungo Card: ");
    printCard( card2 );
    printf(" ");
    winner = playGame( card1, card2, matches1, matches2 );
    if( winner == 1 )
        showWinner( "You", card1, matches1 );
    else if( winner == 2 )
             showWinner( "Computer", card2, matches2 );
    else if( winner == 0 )
             printf(" No one won! ");
   }while( continueFcn() );

system("pause");
return 0;
}


void fillCard ( int card[][SIZE] )
{
   int i, j;
   int c0, c1, c2, c3, c4;
   int col;

   for( i = 0; i < SIZE; i++ )
        {
         for( j = 0; j < SIZE; j++ )
              {
               c0 = rand() % (15-1+1) + 1;
               while( linearSearch(card, col, c0) != -1 )
               c0 = rand() % (15-1+1) + 1;
               card[i][0] = c0;

               c1 = rand() % (30-16+1) + 16;
               while( linearSearch(card, col, c1) != -1 )
               c1 = rand() % (30-16+1) + 16;
               card[i][1] = c1;

               c2 = rand() % (45-31+1) + 31;
               while( linearSearch(card, col, c2) != -1 )
               c2 = rand() % (45-31+1) + 31;
               card[i][2] = c2;

               c3 = rand() % (60-46+1) + 46;
               while( linearSearch(card, col, c3) != -1 )
               c3 = rand() % (60-46+1) + 46;
               card[i][3] = c3;

               c4 = rand() % (75-61+1) + 61;
               while( linearSearch(card, col, c4) != -1 )
               c4 = rand() % (75-61+1) + 61;
               card[i][4] = c4;

               card[2][2] = 0;
               }
         }
}

int linearSearch ( int card[][SIZE], int col, int target )
{
   int i, j;

   for( i = 0; i < SIZE; i++ )
         for( j = 0; j < SIZE; j++ )
               if( target == card[i][j] )
                   return i;
return -1;
}             


void printCard ( int card[][SIZE] )
{
   int i, j;

   printf("   B   I   N   G   O ");
   for( i = 0; i < SIZE; i ++ )
        {
        for( j = 0; j < SIZE; j++ )
             {
              if( card[i][j] == 0 )
                  printf("%s", "FREE");
              else
                  printf("%4d", card[i][j]);
             }
        printf(" ");
        }
}

int playGame ( int card1[][SIZE], int card2[][SIZE], int matches1[][SIZE], int matches2[][SIZE] )
{
    int chosenNumArray[SIZE_NUM_ARR] = {0};
    matches1[SIZE][SIZE] = 0;
    matches2[SIZE][SIZE] = 0;
    matches1[2][2] = 1;
    matches2[2][2] = 1;
    int num;
    int currNum;
  
    do
    {
&nbs

Explanation / Answer

x.P5lor="red">please rate - thanks getting there--look through and see the changes--ignore my intermediate output up to checking for winner #include #include #include #include #include #define SIZE 5 #define SIZE_NUM_ARR 76 #define FLUSH while (getchar() != ' ') void fillCard ( int card[][SIZE] ); int linearSearch ( int card[][SIZE], int col, int target ); void printCard ( int card[][SIZE] ); int playGame ( int card1[][SIZE], int card2[][SIZE], int matches1[][SIZE], int matches2[][SIZE] ); int getNumber ( int chosenNumArray[] ); void displayNumber ( int currNum ); int checkForMatch ( int card[][SIZE], int matches[][SIZE],int ); int checkWinner ( int matches[][SIZE] ); void showWinner ( char nameStr[], int card[][SIZE], int matches[][SIZE] ); int continueFcn ( void ); void printmatches(int[][SIZE],int); int main (void) {    srand(time(NULL));    int card1[SIZE][SIZE];    int card2[SIZE][SIZE];    int matches1[SIZE][SIZE]={0};    int matches2[SIZE][SIZE]={0};    int winner;    do    {     fillCard( card1 );     fillCard( card2 );     printf("Your Bingo Card: ");     printCard( card1 );     printf(" ");     printf("Computer's Bingo Card: ");     printCard( card2 );     printf(" ");     winner = playGame( card1, card2, matches1, matches2 );     if( winner == 1 )         showWinner( "You", card1, matches1 );     else if( winner == 2 )              showWinner( "Computer", card2, matches2 );     else if( winner == 0 )              printf(" No one won! ");    }while( continueFcn() ); system("pause"); return 0; } void fillCard ( int card[][SIZE] ) {    int i, j;    int c0, c1, c2, c3, c4;    int col;    for( i = 0; i