Hi,
I try to generate uniform random number between 0 and 1.
I wrote this code but it creates only numbers at the 0.1***.
Generated number always have 0.1 and remaning numbers change,
like 0.1234, 0.13444,0.143334....
Can you show me show how can I generate these numbers (uniformly) at (0,1].

#include <cmath>
#include <iostream>
#include <limits>
#include <cstdlib>
#include <ctime>
using namespace std;
main ()
{


double AOD;
srand((unsigned)time(NULL));
AOD=((double) rand() / (RAND_MAX+1)) ;
cout<<endl<<AOD;

  std::cout <<"   Press ENTER to continue...";
  std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

return(0);
}
Nick Evan commented: Code tags on first post ! +12

Here's an excellent explanation on how to use rand()

And here's another useful link about main()/void main()/int main()

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.