in , ,

ah yes stackoverflow, short and concise

ah yes stackoverflow, short and concise | code-memes, hacker-memes, stackoverflow-memes, stack-memes, try-memes, c++-memes, random-memes, overflow-memes, IT-memes, cs-memes | ProgrammerHumor.io
code-memes, hacker-memes, stackoverflow-memes, stack-memes, try-memes, c++-memes, random-memes, overflow-memes, IT-memes, cs-memes | ProgrammerHumor.io

Content

I’m trying to generate a random int that is either 0 or 1 in C. Right now, I receive a 0 every time I run this code, and I’m not sure why. What’s the problem here? 24 7 include ctime include cstdlib srand(time (0)); int randomval rand() 2; cout randomval endl; C random ctime share improve this question follow edited Dec 7 ’11 at 21:23 asked Dec 7 ’11 at 21:19 Rich Byden Liatt ness Races in grin begin Rich Byder . 13 344k 63 558 927 8 Answers Active Oldest Votes it is called bad luck. Try it again. 154 share improve this answer follow answered Dec 7 ’11 at 21:22 Michael Krelin – hacker 107k 16 175 164