Using a relay to find a running average

I need to add the function to average the total of the 10 inputs in loop "i" but I can't figure it out. Please help!!!
If it cannot be added to this particular code please point me in the right direction. Thank you!


const int pulsePin = 12; // Input signal connected to Pin 12 of Arduino

int pulseHigh; // Integer variable to capture High time of the incoming pulse

int pulseLow; // Integer variable to capture Low time of the incoming pulse

float pulseTotal; // Float variable to capture Total time of the incoming pulse
float freqVal;
float freqPrint;
int i;
float freqAvg;
int j;
float avgPrint;
float frequency; // Calculated Frequency

void setup() {
Serial.begin(9600);
pinMode(pulsePin, INPUT);

//Serial.print("Instructables");

//Serial.print(" Freq Counter ");
delay(1000);
}

void loop() {
for (j = 0; j < 10; j++) {
for (i = 0; i < 10; i++) {
pulseTotal = 0;
freqVal = 0;
delay(50);
pulseHigh = pulseIn(pulsePin, HIGH);
pulseLow = pulseIn(pulsePin, LOW);

pulseTotal = pulseHigh + pulseLow; // Time period of the pulse in microseconds
if (pulseTotal >= 0.008){
frequency = pulseTotal/10; // Frequency in Hertz (Hz)
}
else {
pulseTotal =0;
frequency = 0;
}
freqAvg = freqVal + frequency;

freqPrint = freqVal/10;
Serial.print(" Frequency: ");
Serial.print (freqPrint);
Serial.println(" Hz");

}
freqAvg = freqAvg + freqPrint/10;

avgPrint = freqAvg/10;
Serial.print ("Average frequency: ");
Serial.print (avgPrint);
Serial.println (" Hz/min");
freqAvg = 0;
avgPrint =0;
freqPrint =0;
}
}

inside your loop "i" you are not summing up anything. Follow the logic of your code. Each time through the loop, you set pulseTotal and freqVal to 0. Then, you add pulseHigh and pulseLow (which are integers) and then expect the result to be greater than 0.008. That will NEVER happen. Therefore, freqAvg will always be zero as well.