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

How would you print a word in a 2d array of ints? What I mean is ifyou have a Bi

ID: 3618946 • Letter: H

Question

How would you print a word in a 2d array of ints? What I mean is ifyou have a Bingo card, how would you print "FREE" at [2][2]element? For example:

Your Bingo Card:
   B   I   N  G   O
13 23 34 55 71
10 30 35 46 75
12 25   0 59 72
   9 16 42 56 67
14 28 41 57 61

Computer's Bungo Card:
   B   I   N  G   O
10 18 35 46 74
12 21 31 47 73
   9 23   0 51 75
14 25 40 53 63
   7 20 41 54 69

How can I make it like that?

Your Bingo Card:
   B    I    N   G    O
13   23   34    55  71
10 30   35    46  75
12 25 FREE 59   72
   9 16    42 56   67
14 28 41    57 61

Computer's Bungo Card:
   B I N   G    O
10 18     35 46 74
12 21    31   47 73
   9    23 FREE 51 75
14 25    40 53 63
   7    20    41 54 69

This is the code I have so far but I don't know how to print theword:

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

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


void fillCard ( int card[][SIZE] );
int linearSearch ( int card[][SIZE], int col, int target );
void printCard ( int card[][SIZE] );
int continueFcn ( void );

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



   do
   {
    fillCard( card1 );
    fillCard( card2 );
    printf("Your Bingo Card: ");
    printCard( card1 );
    printf(" ");
    printf("Computer's Bungo Card: ");
    printCard( card2 );
    printf(" ");
   }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++ )
            {
             printf("%4d", card[i][j]);
            }
        printf(" ");
        }
}


int continueFcn ( void )
{
   char answer;

   printf(" Continue? (N for No): ");
   scanf(" %c", &answer);
   FLUSH;
   printf(" ");
   if( toupper(answer) == 'N' )
       return 0;
   else
       return 1;
}

Thanks!!


Explanation / Answer

//You need to change printCard function only. //Hope this will help you. void printCard ( int card[][SIZE] ) {    int i, j;    printf("   B   I  N   G   O ");    for( i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote