expected unqualified id before token
It looks like you intended the for-loop to run to completion once. If that is correct, just include it and its entire block of code within and at the end of the setup() function. You will still need to provide a loop() function but it can be empty:

void loop(){
   ;
}


If, instead, you wanted the for() loop to be run repeatedly, enclose it in the loop() function:

void loop(){
   for ( k=0; k&lt;=h; k++ )
   {
   ...
   }
}


The setup() function runs once after a power up or reset. The loop function then gets called repeatedly, forever. Put your functional code in whichever one fits your purpose.

The reason for the error message is that, as you've written the for-loop, it is outside of a function, but executable code (as opposed to defining global variables) is only valid within a function.