hi can anyone tell me how to generate random number within certain limit as in between 10 to 20 etc .please help me
Thanks
anuj
anujsharma 0 Newbie Poster
Recommended Answers
Jump to PostInstead of just giving you the code, here's a link to learn to understand how to use rand and srand. Come back if you have any problems with it.
Jump to PostYou didn't 'seed' the random generator with srand(), so your randomnumbers will not be so random :)
Jump to Post>i have tried it in visual studio 2003
From the OP's use of <unistd.h>, which strongly suggests that he's on a POSIX system such as Linux or Unix, I don't think suggesting a C++/CLI solution (a language currently unique to Windows and .NET) is such a hot idea.
Jump to Post>No!...i am using Windows XP!....i have also tried this code on Visual Studio C++ 2008.
Are you really that dense? It doesn't matter one whit what your setup looks like. If your solution doesn't work on the OP's setup, you've been no help at all. Standard C++ supports random numbers. …
All 15 Replies
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
tux4life commented: Hmm, where do I know that site from? :P +5
Dave Sinkula commented: Gotta ++ the site plug. +19
anujsharma 0 Newbie Poster
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
tux4life 2,072 Postaholic
monkey_king 39 Junior Poster
tux4life 2,072 Postaholic
arshad115 -3 Junior Poster in Training
tux4life 2,072 Postaholic
monkey_king 39 Junior Poster
arshad115 -3 Junior Poster in Training
Narue 5,707 Bad Cop Team Colleague
tux4life commented: ROFL :P +6
arshad115 -3 Junior Poster in Training
tux4life 2,072 Postaholic
Narue 5,707 Bad Cop Team Colleague
Salem commented: Well put. +32
BestJewSinceJC 700 Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.