If I run this roulette code (it is inspired by that csgo500 site) on phone, everything works fine, but if i do try it at PC , the maximum generated number is somewhere after 30000, prob the 32768(idk for sure). Why is it working on phone, and why isn't it working on computer?
//Chances for every of the colors to be drawn:
//1.851 - gold
//48.148 - black
//31.481 - red
//18.518 - blue
#include <iostream>
#include<ctime>
#include<cstdlib>
usingnamespace std;
int main()
{
unsigned k,k2,k3,k4;
k=0;
k2=0;
k3=0;
k4=0;
srand((unsigned)time (0));
cout<<" CSGO500 \n\n ";
cout <<"\nHow many times shall the program run?"<<endl;
int n;
cin>>n;
while (n<1)
{
cout <<"Wrong answer"<<endl;
cin>>n;
}
int i;
float x;
for(i=1;i<n;i++)
{
x=1000+rand()%99000; //Generating a float number with 3 decimals by generating a number between 1000 and 100000 then dividing it by 1000(x is a float value variable)
x=x/1000;
if (x<=1.851) {cout <<"GOLD"<<endl;
k=k+1; }
elseif (x>=51.852) {cout <<"BLACK"<<endl; k2=k2+1; }
elseif (x<=33.332&&x>1.851){ cout <<"RED"<<endl; k3=k3+1;}
else {cout <<"BLUE"<<endl;k4=k4+1; }
}
cout <<"\n\nIn total, there were generated "<<k2<<" x BLACK, "<<k3 <<" x RED , "<<k4<<" x BLUE and "<<k<<" x GOLD"<<endl;
cin.get ();
cin.get ();
return 0;
}