hay all i'am new in c++ so i not know the standar library in c++ an so on,
and when i use rand() method it's always show the same number why is that happen?
this is my code please help me.
int i = rand() % 50;
it should return number between 0 and 49 but it just return 42
The rand() function is a seeded random generator. The seed always starts at the same value, and you have to change it with the srand() function. Generally, you call srand(time(0));once at the start of the program, and never again.
Keep in mind that newer C++ standards deprecated the rand() set of functions in favor of the new random number generator library header: http://www.cplusplus.com/reference/random/