I have a problem to ask

I am going to assume that this is school work about arrays so I am not going to give you a fully worked answer but help you do it for yourself.

Since there is no graphics we don’t need a draw() method.

The for loop needs to be in a function in this case setup() so the basic code is

// Global variables

// setup function which is executed once when the sketch starts
void setup(){
  // All your code will go here
}

In terms of global variables you only need the boolean array and an int for the random number which you have already created so lets add that and some pseudocode for the your code

// Global variables
int randomNum;
boolean[] contenitoreVario = new boolean [5];

// setup function which is executed once when the sketch starts
void setup(){
  // pseudocode V V V V V V V V V 
  // for each element in our array
  //    get a random number in the range >=0 and < 100 and store it in our variable
  //   if the number is less than 50
  //      store TRUE in the current array element
  //    else
  //      store FALSE in the current array element
  //     end if 
  //  end for
  // print array
}
2 Likes