I don't know why is not working?
a. Declare an integer constant SIZE to store the number of numbers
b. Declare an array of numbers with size SIZE
c. Fill the array of numbers with random numbers in the range 2-6
That is the code.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ()
{
const int size {6};
int numbers [size];
srand (time(0));
for (int i{0}; i<size; i++) {
numbers[i] = rand()% 3+4 ;
}
cout<<"Random numbers "<<endl;
for (auto number : numbers){
cout<<number << " ";
}
cout<<endl;
}
"is not working" has never been a helpful element of a question.
If you remove the spurious final } then it compiles and runs.
It then generates 6 random numbers between 4 and 6 inclusive. Your question says 2 and 6 inclusive. So fix the line that sets that particular numbers[i].