Float values going astray in IF statement

I am working on this program that gathers pressure readings and compares them using an Uno board and a pressure transducer. I am using an average to filter out noise and it works well when it is out of the IF statement. As soon as it goes inside the IF, my float values show up in my serial as -10x 41 (where x is some random letter, although mostly g or e). I am reading the pressure right above the IF and the serial reads -10.41 which is correct according to the air gauge I have hooked up next to the pressure transducer.

I first tried adding more delays, but there were no improvements. I have also commented out all of the nearby lines and did not see change. When I changed the IF to a WHILE, my program stopped running as soon as it got to the WHILE. All of my variables except the array are floats that are being used in the pressure calculations. What tells me it has to do with the IF is that I copied my pressure acquisition code after the IF and pasted it above the IF and it read perfectly fine.

Any help would be much appreciated.

    int reading[] = {0};
     for(int i = 0; i < 20; i++)
     {
       reading[i] = analogRead(TRANSDUCER);       
     }         
     p = (0.0917 * mean(reading,20)) - 43.059;
      
     Serial.println(p); //debugging printout for the pressure         Outputs good values every time
     
     if(p <= Target_Pressure)          // If the vacuum target pressure is met, start test
     {
     digitalWrite(ON_SOLENOID, LOW);    // Close fill valve                   doesn't seem to make an effect when removed
     delay(1000);                        // Wait for the air to settle
     
     ////////////////////////////////////////////////////////////////////////////////
     // Gather data to get an average of the initial pressure reading.
     ////////////////////////////////////////////////////////////////////////////////
     int reading1[] = {0};
     for(int i = 0; i < 20; i++)
     {
       reading1[i] = analogRead(TRANSDUCER);       
     }         
     p1 = (0.0917 * mean(reading1,20)) - 43.059;      // Outputs goofy value here
     
     Serial.print('A');      // 'A' simply lets me know which pressure I'm seeing
     Serial.println(p1); //debugging printout for the pressure

You are overwriting the end of your two arrays. This:

    int reading[] = {0};
     for(int i = 0; i < 20; i++)
     {
       reading[i] = analogRead(TRANSDUCER);       
     }

declares an array of int which can hold a single int and then your for loop tries to write twenty into it.

agree with wildbill solution use

int reading[20]; // loop will fill automatically.

Ah nice, you guys are champs. It works now. I guess I assumed that Arduino would append on to the array and that was a bad assumption.

I guess I assumed that Arduino would append on to the array...

It will. Unfortunately, it clobbers whatever may be in memory just behind the array.