Posted by speedy11 on 22:30:00 10-11-2001
Thanks for the program for use of the rand() function.
Question answer for:-
Help needed stuck in it.
I done one too see what you think.
#include <stdio.h>
#include <stdlib.h>
#define MIN 20
#define SEC 60
void main()
{
register int a, b;
int people = 0;
for(a=0; a<MIN; a++) /* loop for minutes */
{
for(b=0; b<SEC; b++) /* loop for seconds */
{
if(rand() % 30 == 0) /* check if anyone joins queue */
people++;
if(people > 0) /* if Queue greater than 0 */
if(rand() % 30 == 0) /* chech if anyone leaves */
people--;
}
printf("\nFor minute %d, Queue size was %d", (a + 1), people);
}
return;
}
See I am learning lol.
[ This Message was edited by: speedy11 on 2001-10-11 22:33 ]
[ This Message was edited by: speedy11 on 2001-10-14 00:46 ]
Posted by Sebi on 06:10:00 10-12-2001
but don't u again need a header file if u declare #include twice?
also, try using
int main()
instead of
void main()
just try it... that might delete bugs if there were any...
Posted by Peter on 07:29:00 10-12-2001
First of all, you can't have empty includes. As far as I can see, you need #include <stdio.h>.
A for-loop works according to the following prototype:
for(start_command ; condition ; incremental) {
}
Those command names are of course made up by me and are incorrect, but I hope it will help explaining.
for(i=0 ; i .
Please everybody, disable html for posts with sourcecode!
Posted by speedy11 on 00:48:00 10-14-2001
anony is me now posted as it should be
Posted by Peter on 18:25:00 10-14-2001
Yea, I think that looks good. I am in the evil OS now though so I can not test it. I will later on.