{ 
 srand((unsigned)time(0)); 
 int random_integer; 
 int lowest=-10, highest=10;
 int range=(highest-lowest)+1; 
 for(int index=0; index<8; index++){
     random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
     cout << random_integer << endl; 
    }

Hi there, I'm just getting back into c++ after a 2 year break.
I'm just wondering how I go about using the numbers generated here later on in the program and is there also a way to get I to generate numbers with decimal values as well.

>>how I go about using the numbers generated here later on in the program
1. use global variables (not recommended)

2. make the variables part of a c++ class

3. pass the variables around as parameters to the function(s) that need them.

>>way to get I to generate numbers with decimal values as well
make the variables of type float then divide the value returned by rand() by 100 to get two decimal places.

Hi there, I'm just getting back into c++ after a 2 year break.

You are also hijacking a thread by someone else. Start a new thread with your question, and use CODE tags, not INLINECODE tags for a block of code.

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.