taking average of n sample

Can some one suggest me simple code for taking average of n sample of arduino analog signal.

assume that i have analog sensor, whenever i very output, the reading should get recorded and should return average of n sample recorded

Have you got any code to read the analog value and output the average ?
Can you please post it here - please put it between code tags to make it readable. Read this for advice http://arduino.cc/forum/index.php/topic,97455.0.html

If you can read the analog value then getting the average over a number of readings is simple

In pseudo-code :

set total to 0
set counter to 0
set limit to the number of times to read the value

while counter not equal to limit
  read the current value
  add the value to the total
  add 1 to the counter
  wait a little while
keep going round the loop 
average = total/limit

assume that i have analog sensor, whenever i very output, the reading should get recorded and should return average of n sample recorded

What's the problem. Take n readings, adding them up. Divide by n.

AMPS-N:
Can some one suggest me simple code for taking average of n sample of arduino analog signal.

assume that i have analog sensor, whenever i very output, the reading should get recorded and should return average of n sample recorded

Hi,
consider using the moving average (Moving average - Wikipedia) if you want to continously compute the average of the last N samples.

AMPS-N:
Can some one suggest me simple code for taking average of n sample of arduino analog signal.

assume that i have analog sensor, whenever i very output, the reading should get recorded and should return average of n sample recorded

uint16_t readAnalog(uint8_t port)
{
        uint16_t x, samples;
        uint32_t value;
        value = 0; // init accumulator;
        samples = 1000; // adjust this to your liking

        for(x = 0; x < samples; x++) {
                value += analogRead(port);
        }

        return (value / samples);
}

(edit to add):

If you want to do something like update a display ONLY when the Analog value CHANGES, then use this code as well:

uint16_t old_value = -1; // insure first time around updates

void loop(void)
{
        uint16_t value;
        value = readAnalog(A5); // get averaged analog reading

        if(value != old_value) { // if it changed
                // do something with the new value here
                old_value = value; // update the changed value
        }
}

Hope this helps.

You are already getting the average of 1000 samples (actually 1001)

As the comment in the code says, "adjust this to your liking"
Is the number of samples to be taken fixed or will it change within the program ?