0

Pls i need your help guys in c++ when i try to output a random number it repeat it self how can i solve it

pls guysTry to help me https://code.sololearn.com/c2G2QX0jmljB/?ref=app

5th May 2020, 7:17 PM
Leul Kahssaye
Leul Kahssaye - avatar
5 ответов
0
#include <ctime> // for time() func #include <cstdlib> // for rand() func int main() { srand( time(0) ); std::cout<< rand() % 10<< std::endl; std::cout<< rand() % 10<< std::endl; } edit: dont forget to include other usual things like iostream.
6th May 2020, 8:37 AM
Mustafa K.
Mustafa K. - avatar
0
srand(time(0)); Add this to the first line in main function.
5th May 2020, 9:01 PM
Mustafa K.
Mustafa K. - avatar
0
Can you sent a little code with cpp for this case...........
6th May 2020, 8:24 AM
Leul Kahssaye
Leul Kahssaye - avatar
0
Tnx very much mustefa k. its working now
6th May 2020, 11:57 AM
Leul Kahssaye
Leul Kahssaye - avatar
0
Can you tell me something about layout in code block how can i block ( coded) it and what is the purpose of this layout for my c++ coded program
6th May 2020, 11:59 AM
Leul Kahssaye
Leul Kahssaye - avatar