Hello,
I am writing a program that generates random numbers with in the range [0,2].
I want to keep track of how many zeros are generated. I thought I had it with my if statement but it does not increment correctly. counter2 will increment sometimes when rand()%2 == 0 and other times not. Then it will also increment when rand()%2 == 1 or 2. Please help. Thanks
1) rand() % 2 can generate onlt 0 or 1
2) Line 17: you are generating random number and outputting it on the screen.
Line 24: you are generating another different random number and testing it for 0;
Any way someone could hint at how to reference the same pool of random numbers when calling rand() twice in same program? I am a struggling to figure it out. Thanks for the reply MiiNiPaa.