I was thinking you'd create two versions of CreateRandomNumber, one like this:
int CreateRandomNumber()
{
// returns a random number
// used as in:
// int x = CreateRandomNumber();
}
the second version would look like:
void CreateRandomNumber(int)
{
// sets the passed in variable to a random number
// used as in:
// int x = 0;
// CreateRandomNumber(x);
// x is now assigned a random value
}
The tricky part of the second functions lies in passing in x so that it can be modified.
The try/catch allows trying a statement and catching any exceptions that it throws. Your example doesn't actually throw an exception, so a try/catch won't work - you'll have to do an if(..) to test if what they enter is a number. But it would be good to learn about try/catch anyhoo
My MSN is I was thinking you'd create two versions of CreateRandomNumber, one like this:
int CreateRandomNumber()
{
// returns a random number
// used as in:
// int x = CreateRandomNumber();
}
the second version would look like:
void CreateRandomNumber(int)
{
// sets the passed in variable to a random number
// used as in:
// int x = 0;
// CreateRandomNumber(x);
// x is now assigned a random value
}
The tricky part of the second functions lies in passing in x so that it can be modified.
The try/catch allows trying a statement and catching any exceptions that it throws. Your example doesn't actually throw an exception, so a try/catch won't work - you'll have to do an if(..) to test if what they enter is a number. But it would be good to learn about try/catch anyhoo
My MSN nerseus_mcsd though I can't connect right now. I have ICQ and Yahoo if you have them.
As for posting the source, don't worry about it. The point is for
you to understand what's going on and feel confident enough to move forward
-Nerseus