Code:result = rand(); // generate random value from 0 to 32767 result = result/1000;
But the switch-case on your code considers only 10 options (0 to 9), which means that would be expected a lot of raffles without any update on the lottery display, something in the range of 1/3 ( ~10/32 )
Even though it's not the most uniform solution, The OP could have just done the following:
Code:
result = rand()%10; // generate a random value from 0 to 9
That is easier to understand and produces only numbers from 0-9 without having to deal with runs of results outside that range.