#include #include #include #include #include #include #include #include main() { float mean,variance,std_dev,sum,*a; int n,i; char resp[10]; clrscr(); printf("\nThis program will find the mean,variance and standard deviation of the given n \nnumbers\n\n"); do { printf("\nHow many elements do you want to enter:"); scanf("%d",&n); a = malloc(sizeof(float *) * n); /*allocate memory*/ printf("\nEnter the numbers:"); for(i = 0;i < n;i++) scanf("%f",a+i); sum = 0; /*reset accumulator sum*/ for(i = 0;i < n;i++) sum += *(a+i); mean = sum/n; sum = 0; /*reset accumulator sum*/ for(i = 0;i < n;i++) sum += pow((*(a+i) - mean),2); variance = sum/n; std_dev = sqrt(variance); printf("\n\tMean = %.3f\n\tVariance = %.3f\n\tStandard Deviation = %.3f",mean,variance,std_dev); printf("\n\nDo for another set of values(y/n) "); scanf("%1s",resp); } while(*resp == 'y' || *resp == 'Y'); printf("\n\n\nWaiting for you to hit a key"); getch(); print_rajesh(); return; /*keep the compiler happy*/ }