Вы находитесь на странице: 1из 1

/*CHIN WEI RONG HS27 BS12110088*/ #include<math.h> #include<stdio.h> #include<conio.

h> #define Max 100 main() { float Data[Max+1]; float MEAN, VAR, STD, SUM; int i, n; char repeat; do { fflush(stdin); clrscr(); printf("\n\t~ Welcome to the Mean, Variance & Standard deviation Calculator ~"); do { printf("\n\n\n\nHow many data do you have [ < 100 ] scanf("%d", &n); }while(!((n>0)&&(n<Max))); for(i=0; i<n; i++) { printf("\n\nEnter your Data [%d] scanf("%f", &Data[i]); } SUM = 0.0; for(i=0; i<n; i++) SUM = SUM + Data[i]; MEAN = SUM/n; SUM = 0.0; for(i=0; i<n; i++) SUM = SUM + pow(Data[i] - MEAN, 2.0); VAR = SUM/(n-1); STD = sqrt(VAR); printf("\n\nThe Mean is %.4f", MEAN); printf("\nThe Variance is %.4f", VAR); printf("\nThe Standard Deviation is %.4f", STD); printf("\n\n\n\nDo you want to repeat again? repeat=getch(); }while((repeat=='Y')||(repeat=='y')); getch(); return 0; } ( YES/Y or NO/N )" );

");

", i+1);

Вам также может понравиться