I can generate a set of random numbers, but I need to get them into an array. Can someone please help me? If I cout << number after the rand it prints me out a list, but I can't seem to get it into the array. Here is what I have:
*/
//********************************** Includes
#include <cfloat>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cctype>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
#include <conio.h>
#include <windows.h>
#define cls system("cls")
#define frz system("pause");
#define yl system("color 0e");
usingnamespace std;
//********************************** Type definitions
//********************************** Function Prototypes
//********************************** Main Function
int main()
{
time_t t;
time(&t);
yl;
cls;
srand((unsignedint)time(NULL));
int data[45]; //<---take out the int
int number;
int i, j, k, high, low;
high=206;
low =147;
int count=0;
for(i=0;i<45;i++)
{
data[i] = 0;
} // end for i
for (i=93;i<=139;i++)
{
number=rand()% (high-low+1) + low;//
data[i]=number;
cin >> data[i]; //<---you are overwriting what you did in the previous line
i++;
}//end for i
well your code is completely screwed up.
you declare an array of 45 ints, but in the second "for" loop you just ignore top array bound. why don't you use ? just one loop, there is no need to fill array with 0s.
1 2
for (int i = 0; i < 45; i++)
data[i] = rand() % (high - low + 1) + low;