Hello,

I am writing a program to read a series of numbers then calculate average, geometric mean and harmonic mean. I'm not sure if my formulas are entered correctly. Any thoughts, (not good at math)

Code:/*this program will calculate the average, geometric mean and harmonic mean of a series of 5 pos numbers. written by: Patricia Stephens Date: June 2009 */ #include<stdio.h> #include "stdafx.h" #include "math.h" #define M 5 int main(void) { //local declarations int i; int sum; int avg; int n; sum=avg=0; //Statements printf("please enter 5 whole numbers then key <EOF> to stop(CTRL+D OR CTRL + Z\n"); for (i=0; i<=M; i++) { scanf_s("%2d",&n); sum=sum+n; } printf("the sum is %2d\n", ((sum)-n)); printf("the average is %2d\n", (int(sum)/n)); printf("the harmonic mean is %f\n", (n/float(sum)/1)); printf("the geometric mean is %f\n", pow(sum,1.0/n)); return 0; }//main