/* Accepts 4 numbers a, b, c, d as double and finding their arithmetic mean (AM), geometric mean (GM) and harmonic mean (HM) and prints the mean that is neither the largest nor the smallest (i.e., the middle value). * Author:rahule@cse.iitk.ac.in */ #include #include int main() { double a,b,c,d,am,gm,hm; //variable initialization printf("\nEnter four numbers:"); scanf("%lf%lf%lf%lf",&a,&b,&c,&d); am=(a+b+c+d)/4; //finds Arithmatic mean using the formula AM=(a+b+c+d)/4 gm=sqrt(sqrt(a*b*c*d)); //finds goematric mean using the formula GM=sqrt(sqrt(a*b*c*d)) hm=4/((1/a)+(1/b)+(1/c)+(1/d)); //finds Harmonic mean.Alternately,if one knows AM and GM,harmonic mean can also be calulated as HM=GM^2/AM printf("\nArithmatic Mean:%lf\n",am); printf("\nGeometric mean:%lf\n",gm);printf("\nHarmonic Mean:%lf\n",hm); printf("\nThe middle value is the "); if(((am<=gm)&&(gm<=hm))||((hm<=gm)&&(gm<=am))) //if am