use of random() and randomize() in C++ -


please explain me how code providing gives output :

1 2 3 4 5 6 7 8 9 10 11

#include<stdlib.h> #include<iostream.h>  int main() {    randomize();    int num, rndnum;     cin >> num;     rndnum = random(num) + 7;    (int n =1; n<=rndnum; n++)          cout << n <<""; } 

please explain me code snippet

well taking input num user , passing random() function. taking returned value function , adding 7 , assigning rndnum. looping through 1 rndnum , printing of each of numbers (1, 2, ...., rndnum).

in case of printing out 1 - 11 must have gotten return value of 4 random(num).


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -