Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: thebestitme on April 12, 2019, 11:16:17 am

Title: problem with random function
Post by: thebestitme on April 12, 2019, 11:16:17 am
Hello , I have a problem with random function. First, I have to explain that I make a question and random it.
I  use 
srand(time(NULL));
QUIZ = rand()%38;
but it always show question no. 36 then I answer it shows another question.

If I delete it to have only question no. 0-35 , it doesn't has any problem although I use the same code.

https://www.img.in.th/images/51327cfda1b4948729a1f110f72f6842.png

https://www.img.in.th/images/639216882954c3b51809100ccb6dc936.png

thank you
Title: Re: problem with random function
Post by: thebestitme on April 12, 2019, 11:52:40 am
I try not to use (Z==36)  so I skip it to the next number and it works !
Title: Re: problem with random function
Post by: sodev on April 12, 2019, 06:56:32 pm
This is not a Solve-My-Homework forum, as can be seen on the screenshots your CodeBlocks is working fine. So not a CodeBlocks problem, wrong forum, you have to look somewhere else.