# random numbers

• 01-18-2005
ballmonkey
random numbers
I had a look at the random numbers tutorial and was wondering why doesn't this work???

Code:

```#include <iostream> #include <stdlib> #include <time> /* These constants define our upper and our lower bounds. The random numbers will always be between 1 and 6, inclusive. */ const int LOW = 1; const int HIGH = 3; int main() { /* Variables to hold random values for the first and the second die on each roll. */ int first_die, sec_die; /*Ê Declare variable to hold seconds on clock. */ time_t seconds; /* Get value from system clock and place in seconds variable. */ time(&seconds); /* Convert seconds to a unsigned integer. */ srand((unsigned int) seconds); /* Get first and second random numbers. */ first_die = rand() % (HIGH - LOW + 1) + LOW; sec_die = rand() % (HIGH - LOW + 1) + LOW; /* Output first roll results. */ cout<<"I chose the mighty\n"; if ( first_die == 1 ) {   cout<<"Paper!\n"; } else if ( first_die == 2 ) {     cout<<"Rock!\n";     } else {     cout<<"Scisors!\n";     }     cout<<"I like the number "<< sec_die << "}" << endl << endl; cin.get(); /* Get two new random values. */ first_die = rand() % (HIGH - LOW + 1) + LOW; sec_die = rand() % (HIGH - LOW + 1) + LOW; /* Output second roll results. */ cout<< "My roll is (" << first_die << ", " << sec_die << "}" << endl << endl; cin.get(); }```
It says thet cout is unidentified, why's this?

Thanks
• 01-18-2005
Stack Overflow
Hello,

For a simple answer and example, view the following link: C++ Tutorial: 5.2, Namespaces

Scroll down until you find the Namespace std sub-section. It should answer your question.

- Stack Overflow
• 01-18-2005
ballmonkey
Ok, thanks.

--edit--

Oh my god! How the heck did I not put using namspace std??? That's the first time I've ever done that! Also I copied that off this website, I think the admin should have a look at the rand numbers tutorial.
• 01-18-2005
sean
Quote:

I think the admin should have a look at the rand numbers tutorial.
There are actually a lot of problems with the tutorials, but it's a tough job to fix all the mistakes. The administrators all have full-time jobs, and they put in a lot of work maintaining the site as it is.