URGENT! generating double number

i need to generate a double number and i asked my instructor and forgot to send myself the file, my data is lost and i need help about but i remember he said something like this

 
  Value[SIZE] =double(((rand()%(MAX-MIN+1))+MIN)/10);



my MAX and MIN and Value[SIZE] are double values but the program doesn't work.
It says something like
IntelliSense: expression must have integral or unscoped enum type

I made my MAX and MIN integers but now it says that that value is overrun. What should i do?
Last edited on
http://www.cplusplus.com/faq/beginners/random-numbers/

The rand() function has a limited range. If you are using C++, use the C++ methods to get random numbers:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <chrono>
#include <iostream>
#include <random>

int main()
{
  // Get values in [10,200)
  constexpr double MIN = 10;
  constexpr double MAX = 200;
  std::mt19937 prng( std::chrono::system_clock::now().time_since_epoch().count() );
  prng.discard( 10000 );
  std::uniform_real_distribution<double> random( MIN, MAX );

  // Get an array of values
  constexpr std::size_t SIZE = 3;
  double values[ SIZE ];
  for (double& value : values)
    value = random(prng);

  // Print all the values in the array
  for (double value : values)
    std::cout << value << "\n";
}

Hope this helps.
Topic archived. No new replies allowed.