// average.nqc// sensors#define BUTTON	SENSOR_1#define EYE		SENSOR_2// number of samples#define N	3// average needs to be global for displayint average = 0;// this function waits for a press and// release of the touch sensorvoid wait_for_touch(){	until(BUTTON == 1);	until(BUTTON == 0);	PlaySound(SOUND_CLICK);}task main(){	int index;	int current;	int samples[N];	int total = 0;		// setup sensors and display	SetSensor(BUTTON, SENSOR_TOUCH);	SetSensor(EYE, SENSOR_LIGHT);	SetUserDisplay(average, 1);	// start with N samples	for(index=0; index<N; ++index)	{		wait_for_touch();				current = EYE;		samples[index] = current;		total += current;	}		PlaySound(SOUND_UP);	index = 0;		while(true)	{		// compute the average		average = total * 10 / N;		// get new sample		wait_for_touch();		current = EYE;				// replace sample		total -= samples[index];		total += current;		samples[index] = current;				// adjust index		++index;		if (index==N) index = 0;	}	}