+ 3

How to take random command in cpp?

means putting a random value

26th Nov 2017, 8:07 AM
Subrahmanya Mayya
Subrahmanya Mayya - avatar
2 odpowiedzi
+ 3
What do you mean random command? can you give more details about what you want to achieve?
26th Nov 2017, 8:23 AM
Ipang
+ 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.
10th Dec 2018, 6:45 PM
mohammad reza abbasniya
mohammad reza abbasniya - avatar