Stuck with program flow and freezing programm

    int reading = 0;                                  //the readings
     for(int i=0; i<15; i++){                      //take 15readings
      int value = analogRead(lightSensor);
      reading = reading + value;
    }

Have you ever wondered why the language we use to program the Arduino wasn't called C=C+1? Why do you need a local variable in the loop?

     int reading = 0;                                  //the readings
     for(int i=0; i<15; i++)
     {                      //take 15readings
         reading += analogRead(lightSensor);
     }