Code:
/*
* Program: BINGO
* Author: Mark Smith
* Date: 4/9/09
* Input:
* Output:
* Description:bingo game project 3
* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void about();
void copyrandword(char *word);
void assignwords(char card[5][5][30]);
char BingoWords[75][30]={"acid","atom","average","axis","base",
"bonding","circuit","chemical","dispersion","derivative",
"electricity","electron","energy","engineer","equation","force",
"friction","flammable","fluorine","fusion","if-then-else",
"getchar","gets","grams","gas","ideal gas law","integer",
"inertia","integral","joule","kilogram","Kalvin","liter","liquid",
"longitude","meter","math","mole","milliliter","molecule","Newton",
"neutron","nucleus","optics","orbitals","p-orbital","pounds",
"proton","pressure","quark","resistor","s-orbital","science",
"scientist","stoichiometry","strain","stress","solution","time",
"tension","Uranium","variables","variance","velocity","virtual",
"waves","wavelength","weight","x-axis","X-ray","Xenon","y-axis",
"Yttrium","z-axis","Zinc"};
void displaycard();
void wordtest();
void gamewinner();
int main()
{
int i;
//create card
char cardObject[5][5][30];
srand(time(NULL));
about();
assignwords( cardObject );
printf("\n");
printf("| B |");
printf(" I |");
printf(" N |");
printf(" G |");
printf(" O |");
printf("\n");
//print all words
for(i=0;i<75;i++)
{
printf("| %s |", BingoWords[i]);
if (i%5==0)
{
printf("\n");
}
}
return(0);
}
void about()
{
printf(" WELCOME TO WORD-BINGO!\n");
printf("This is a two player game. Each player is given\n");
printf("one BINGO card. Instead of numbers or symbols, this\n");
printf("BINGO game involves words related to math, science, and\n");
printf("engineering.");
}
void copyrandword(char *word)
{
int i=rand() % 75;
strcpy(word, BingoWords[i]);
}
void assignwords( char card[5][5][30])
{
int i, j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
copyrandword( card[i][j] );
}
}
}
void displaycard( char card[5][5][30])
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
copyrandword( card[i][j] );
}
}
for(i=0;i<25;i++)
{
for(j=0;j<25;j++)
{
printf("| %s ", card[i][j]);
if((i%5)==0)
{
printf("\n");
}
if(card[i][j]=card[3][3])
{
printf("| FREE ");
}
}
}
}