Hi guys
I'm trying to generate a radnom float number between 1.2 and 2.3 but when compile I get this error:
cal.cpp: In function `int main()':
cal.cpp:13: error: invalid operands of types `int' and `double' to binary `operator%'
the code:
int main()
{
srand(time(NULL));
float num;
num = rand() % ( (2.3 - 1.2) + 1 ) + 1.2;
cout << " Random number = " << num << endl;
return 0;
}
Thanks for your help