How could you make an array with 20 to 30 random elements. Then, I want each element to have a random number between 100 to 200. I have written the random number for each element, but how do you make a random amount of those elements as well? I know I need to use functions and loops. I want something like this:
#include <iostream>
#include <time.h>
#include <stdlib.h>
usingnamespace std;
int main()
{
int iseed = (int)time(NULL);
int n;
srand(iseed);
n = 100 + rand ()% 100; // 100 to 200 random number
return 0;
}
Each array ELEMENT has a different random value N.
X is a random number between 20 to 30. (This means you have from 20 to 30 array Elements).
Must use your randint(min, max) function to return value into X!
N is a random number between 100 to 200. (This means that each Element is a random number between 100 to 200).
Must use your randint(min, max) function to return value into each N!