I need some help with Bingo written in C++

If anyone can help me, it you would be much appreciated

Page 1 of 1

4 Replies - 815 Views - Last Post: 04 March 2009 - 09:03 PM Rate Topic: -----

#1 caleb325  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-March 09

I need some help with Bingo written in C++

Post icon  Posted 03 March 2009 - 08:23 PM

Ok, I have to write a program for Bingo. I dont have much to start with, but see if you can help me.

//Bingo

#include <iostream>
#include <ctime>
#include <iomanip>
#include <cstdlib>

using namespace std;
int cat;
int bingo [5][5];
int main()

{
	int randomNumber = rand(); // generate random number
	int die = (randomNumber % 75) + 1; // get a number between 1 and 75
	
	column B 1 - 15 
	column I 16 - 30 
	column N 31 - 45 
	column G 46 - 60 
	column O 61 - 75 





cin >> cat;
return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: I need some help with Bingo written in C++

#2 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5351
  • View blog
  • Posts: 27,306
  • Joined: 10-May 07

Re: I need some help with Bingo written in C++

Posted 03 March 2009 - 08:26 PM

** Renamed title to be more descriptive **

What do you need help with... you just posted some code. Please try to be a little more specific :)
Was This Post Helpful? 0
  • +
  • -

#3 Hyper  Icon User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: I need some help with Bingo written in C++

Posted 03 March 2009 - 09:14 PM

[rules][/rules]

What no2pen said.
Was This Post Helpful? 0
  • +
  • -

#4 caleb325  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-March 09

Re: I need some help with Bingo written in C++

Posted 04 March 2009 - 08:39 PM

Okay, now I need help with getting the prgram to give a random number generator to generate numbers like from say 16-30 like for each letter on bingo.

//Bingo

#include <iostream>
#include <ctime>
#include <iomanip>
#include <cstdlib>

using namespace std;
int cat;
int bingo [5][5];
int main()

{
	cout << " Welcome to BINGO! \n\n\n\n\n" << endl;
	cout << "\n\n\	 B | I | N | G | O |\n	- - - - - - - - - - - "  << endl;
							  
	int randomNumber = rand(); // generate random number
	int die = (randomNumber % 75) + 1; // get a number between 1 and 75
	char board[5][5];{
	board [0][0] = (randomNumber % 15) + 1;
	board [1][0] = (randomNumber % 15) + 1;
	board [2][0] = (randomNumber % 15) + 1;
	board [3][0] = (randomNumber % 15) + 1;
	board [4][0] = (randomNumber % 15) + 1;
	board [0][1] = (randomNumber % 30) + 1;
	board [1][1] = (randomNumber % 30) + 1;
	board [2][1] = (randomNumber % 30) + 1;
	board [3][1] = (randomNumber % 30) + 1;
	board [4][1] = (randomNumber % 30) + 1;
	board [0][2] = (randomNumber % 45) + 1;
	board [1][2] = (randomNumber % 45) + 1;
	board [2][2] = (randomNumber % 45) + 1;
	board [3][2] = (randomNumber % 45) + 1;
	board [4][2] = (randomNumber % 45) + 1;
	board [0][3] = (randomNumber % 60) + 1;
	board [1][3] = (randomNumber % 60) + 1;
	board [2][3] = (randomNumber % 60) + 1;
	board [3][3] = (randomNumber % 60) + 1;
	board [4][3] = (randomNumber % 60) + 1;
	board [0][4] = (randomNumber % 75) + 1;
	board [1][4] = (randomNumber % 75) + 1;
	board [2][4] = (randomNumber % 75) + 1;
	board [3][4] = (randomNumber % 75) + 1;
	board [4][4] = (randomNumber % 75) + 1;
}
	





	cin >>cat;
	return 0;
}


Was This Post Helpful? 0
  • +
  • -

#5 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: I need some help with Bingo written in C++

Posted 04 March 2009 - 09:03 PM

I suggest you write a function that generates a random number in a specified range, e.g.,

int getRandomNumber(int min, int max)
{
	int number;

	number = (rand() % ((max - min) + 1)) + min;

	return number;
}
.

I would also suggest you use a loop to initialize the board array.

This post has been edited by bsaunders: 04 March 2009 - 09:29 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1