To count # of games/Limit the # of games
Author Message
To count # of games/Limit the # of games

Hi,

I'm a student at DeVry... in C programming at this time.  I have a
project where I'm trying to accomplish among other things, two in
particular.  It is the random number game set for random numbers between
1 and 100 and the person guesses up to so many tries.  There are scanf
and printf functions used to accomplish this with a for loop and a do
while loop.  The two things I'm trying to do which I'm having problems
with are:

1) To count the number of games played by user.
2) To Limit the number of games played by user to 5.

I can get it to do either but not both.  Any suggestions from this brief
description of the problem?

--
=================================================

Ken's Family Cottage Homepage
http://www.*-*-*.com/ ~kn/

Thu, 08 Feb 2001 03:00:00 GMT
To count # of games/Limit the # of games

Quote:

> The two things I'm trying to do which I'm having problems
> with are:

Hi Ken Branham,

Quote:
> 1) To count the number of games played by user.

Declare:                 int gameCounter = 0;
Later in the code do:    gameCounter += 1;

Quote:
> 2) To Limit the number of games played by user to 5.

if ( gameCounter > 5 )
{
printf( "Sorry, that's it. You're out.\n" );
exit( 0 );
}

Quote:
> I can get it to do either but not both.

Huh ? What is your precise problem ?

Quote:
> Any suggestions from this brief description of the problem?

See above. It appears to be a very simple task. If my solution
Maybe post a small (hopefully complete) sample program that

Stephan
(initiator of the campaign against grumpiness in c.l.c)

Fri, 09 Feb 2001 03:00:00 GMT
To count # of games/Limit the # of games
Groovy hepcat Ken Branham was jivin' on Sun, 23 Aug 1998 19:28:12
-0400 in comp.lang.c.
To count # of games/Limit the # of games's a cool scene! Dig it!

Quote:
>particular.  It is the random number game set for random numbers between
>1 and 100 and the person guesses up to so many tries.  There are scanf
>and printf functions used to accomplish this with a for loop and a do
>while loop.  The two things I'm trying to do which I'm having problems
>with are:

>1) To count the number of games played by user.
>2) To Limit the number of games played by user to 5.

>I can get it to do either but not both.  Any suggestions from this brief
>description of the problem?

Yes. Post some code. We can hardly be expected to know what's wrong
with your program if we can't see any of it.
So, please post the smallest possible *compilable* piece of code
that demonstrates the problem.
--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============

Mon, 12 Feb 2001 03:00:00 GMT
To count # of games/Limit the # of games
Peter,

Ken

Quote:

> Groovy hepcat Ken Branham was jivin' on Sun, 23 Aug 1998 19:28:12
> -0400 in comp.lang.c.
> To count # of games/Limit the # of games's a cool scene! Dig it!

> >particular.  It is the random number game set for random numbers between
> >1 and 100 and the person guesses up to so many tries.  There are scanf
> >and printf functions used to accomplish this with a for loop and a do
> >while loop.  The two things I'm trying to do which I'm having problems
> >with are:

> >1) To count the number of games played by user.
> >2) To Limit the number of games played by user to 5.

> >I can get it to do either but not both.  Any suggestions from this brief
> >description of the problem?

>   Yes. Post some code. We can hardly be expected to know what's wrong
> with your program if we can't see any of it.
>   So, please post the smallest possible *compilable* piece of code
> that demonstrates the problem.
> --

> ----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

> -------------- Shaggy was here! ---------------
>     http://aardvark.apana.org.au/~phaywood/
> ============= Ain't I'm a dawg!! ==============

--
=================================================

Ken's Family Cottage Homepage
http://www.asacomp.com/~kn/

Mon, 12 Feb 2001 03:00:00 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages