- 1

Hello, how can I randomly output two elements from the char array?

https://code.sololearn.com/cdu7BMFDrOmB/?ref=app

26th Mar 2021, 1:06 PM
TeaserCode
2 Answers
+ 1
Remove line 20 and change line 21 to: cout << c[rand() % 7] << " "; So that the loop should look like: for(int i=0; i<2; i++) { cout << c[rand() % 7] << " "; } Works for me. Note that rand() is from C language and it is recommended to use the <random> library in C++.
26th Mar 2021, 1:14 PM
Luk
Luk - avatar
0
It works at me too. Thanks.
26th Mar 2021, 2:53 PM
TeaserCode