Appending loop count to int name

How do I append the loop number to the variable name [Var]

int Val1 = 5;
int Val2 = 1;
int Val3 = 2;

for (int x = 1; x <= 3; x++) { // loop display and sound tone if needed 6 times @ 10sec

if (Val > 3){

Serial.println(“Do something”);



You don’t (can’t).
Use an array.
And code tags.

int Val [3] = { 5, 1, 3};
for (int x = 0; x < (sizeof(Val) / sizeof(Val[0])); x++) {
   if (Val [i]  > 3){
      Serial.println("Do something");
int val[] = { 5, 1, 2 };

for ( int i = 0; i < 3; i++ )

The compiler replaces all names with addresses. When the code is running, it has no idea that you think of a memory location as having a name. So, constructing a string of the name will NOT get you an address.

As AWOL says, if you put your values in an array, the data is stored contiguously in memory, so val[i+1] is adjacent to val[ i ]. You can iterate over the array, and test the values the way you (appear) to suggest.

Sorry, I guess I should have worded my question a little differently.

All the [int Val]'s have been populated from previous code. These are just examples. int Val1 = 5; int Val2 = 1; int Val3 = 2;

The answer remains the same. Either put the values into an array, or make sure the previous code put them in an array

I put the values into an array and worked like a charm.

Thank You very much!