+ 1

How do you make a random number generator with C++?

I made a random number generator earlier and it was really long and took me a long time. Then the stupid coding template on this website start messing up and I want to know how you can make a easier generator or stop the code from ****ing with me.

6th Nov 2016, 6:47 PM
Maurice Pennington
Maurice Pennington - avatar
2 Respostas
+ 1
#include <iostream> #include <ctime> using namespace std; int main() { srand(time(0)); int num; cout << "Random number from 1 to... "; cin >> num; cout << "Random number: " << rand() % num + 1; return 0; }
6th Nov 2016, 7:08 PM
Cohen Creber
Cohen Creber - avatar