ftp.nice.ch/pub/next/science/physics/delta-sigma.s.tar.gz#/delta-sigma.src/dsp/average.c

This is average.c in view mode; [Download] [Up]

#include <stdio.h>

main(int argc, char *argv[]){
double v, total=0;
long int n=0, N=-1;
if( argc > 1 )
    N = atoi(argv[1]);
while( scanf("%lf", &v) > 0 ){
    n++;
    total += v;
    if( n==N ){
	printf("%f\n", total/n);
	n=0;
	total = 0;
	}
    }
if( n!=0 )
    printf("%f\n", total/n);
fflush( stdout );
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.