+ 2

Can anyone explain me the following code?

#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main () { srand(time(0)); for (int x = 1; x <= 10; x++) { cout << 1 + (rand() % 6) << endl; } }

11th Feb 2017, 4:22 PM
Nithyapriya
1 ответ
+ 10
The code outputs 10 random numbers ranging from 1 to 6.
11th Feb 2017, 4:28 PM
Hatsy Rei
Hatsy Rei - avatar