help for the program for water tank

int x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15;

one day long ago in FORTRAN someone invented the array. In C++ it is written as

int x[16] = { 0,10,20,25,30, ....,0,0,0}

everywhere where you state x3 you should use x[3] (and that for all values of 3 :wink:


The other trick to consider is the else keyword

void display(int z)
{
  if (a==0 && b==0 && c==0 && d==0)  // spaces are free
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[0]); 
  else if (a==0 && b==0 && c==0 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[1]); 
  else if (a==0 && b==0 && c==1 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[2]); 
  else ...
//etc
}

As you want to handle all 16 possible combinations of bits you can combine the values a,b,c,d into one integer by using bit math to create an index to the array declared above.

void display(int z)
{
  int index = a*8 + b*4 + c*2 + d; 
   printf("%d, %d, %d, %d is %d %%", a, b, c, d, x[index]); 
}

please read the tutorial pages about arrays in C for more info.