+ 1

how does a rand() works?

#include <iostream> #include <cstdlib> using namespace std; int main() { for (int x = 1; x <= 10; x++) { cout << rand() << endl; } } every time how it's output can be same?

25th Sep 2017, 2:38 PM
Shivani Goyal
2 Respostas
+ 6
See it does produce random values but they are same at each execution If u want different values at each execution use srand();
7th Oct 2017, 7:26 PM
Abhishek Tandon
Abhishek Tandon - avatar
7th Oct 2017, 7:27 PM
Abhishek Tandon
Abhishek Tandon - avatar