Floating point exception occurs when x%0
happens.
In your code it must be concurring here:
roll(){
int val = rand() % slotNumber;
slotNumber = val++;
}
Case: if rand()
generates a multiple of 5
val becomes 0 and slotNumber gets set to 0, next time roll()
is called it crashes