BeIng the aspIrIng programmer I am, I was fIddleIng wIth the numbers and operatIons of thIs random number generator I found onlIne. I tInkered wIth It long enough to get the output to be truly random, but Its output Is InfInite. I want It to generate one number at a tIme, or at least somethIng more manageable.

code blocks, nice choice 8) same one i use. if you're trying just a random number generator, that is way too complicated. i tried it, and all i got was the number 1 in an infinite loop. for a short and simple random number generator, here's what you want

i highly recommend this video tutorial series, since it's the one i follow, and easiest for me to understand. here's a playlist, so you can add it to your account, if you wish to do so.

HeroKing wrote:code blocks, nice choice 8) same one i use. if you're trying just a random number generator, that is way too complicated. i tried it, and all i got was the number 1 in an infinite loop. for a short and simple random number generator, here's what you want

[youtube][youtube]

i highly recommend this video tutorial series, since it's the one i follow, and easiest for me to understand. here's a playlist, so you can add it to your account, if you wish to do so.

If you don't even understand why you have an infinite loop here, I don't think you should go on with that. Start learning programmation from the beginning (conditions, loops, ...).

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(0));
for(int x = 1; x<2;x++) {
cout << "This is what you rolled:\n" << endl;
cout << 1+(rand()%20) << endl;
}

for one thing, you seem to be missing another } to end your function. and Jivix is right, since that for loop will only work once. i'll show you a header function i wrote for a simple coin toss program i came up with.