+ 3
How to take random command in cpp?
means putting a random value
2 odpowiedzi
+ 3
What do you mean random command? can you give more details about what you want to achieve?
+ 2
#include <iostram>
#include <cstdlib>
#include <time.h>
using namespace std;
int main(){
srand(time(NULL));
int x=rand();
int y=rand();
}
--------------------------
Srand () function chooses a seed and each call for rand() returns a random value...
You can limit the returned value by this structur:
X = rand()% m;
In this case , the random value will be between 0 and m.
Good luck.