Get just one output out of this

I just want one random number not two for this:
1
2
3
4
5
6
srand(time(0));
for (int i=0; i<=1; i++)
    {
        r = rand() % 2;
		cout << r << endl;
	}



It outputs 1 and 0 or whatever it randomizes. I just want ONE zero or ONE one.
so it starts at zero then executes the code then goes to one and does it again
how do i change it so i doesnt do it twice
Take out the for loop.

1
2
3
srand(time(0));
int  r = rand() % 2;
cout << r << endl;


Topic archived. No new replies allowed.