Stared implementing averaging of multiple scans in c