int intrnd (int& seed)
{
#if LONG_MAX > (16807*2147483647)
int const a = 16807;
int const m = 2147483647;
seed = (long(seed * a))%m;
return seed;
#else
double const a = 16807;
double const m = 2147483647;
double temp = seed * a;
seed = (int) (temp - m * floor ( temp / m ));
return seed;
#endif
}
I Hope this code is beneficial for you and if you want to more details about PLC Programming so you can visit my link
Thanks and Best Regard
Visit Link:-
http://www.cetpainfotech.com/technology/plc-and-scada-training