+ 1

Can you output random letters using <ctime>&<cstdlib>

26th Dec 2016, 1:28 AM
smartguy100
smartguy100 - avatar
2 Answers
+ 9
You can. But first, you need to find out the range of ASCII values of the letters you want to be randomly printed. srand(time(0)); for(int i = 0; i < 5 ; i++) { int x = rand() % value_range; cout << static_cast<char>(x); } // outputs 5 random chars within a ASCII value range
26th Dec 2016, 3:38 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Try it and find out. That's the best way to learn.
26th Dec 2016, 1:29 AM
Ben
Ben - avatar