You are on page 1of 2

AVERAGE AND STANDARD DEVIATION OF N NUMBERS ( N IS NOT PREDETERMINED )

. PROGRAM/CODE: #include<stdio.h> #include<conio.h> #include<math.h> main() { int i,n; float a[100],sum,mean,ssd,var,sd; printf("Finding Mean and Standard Deviation of Given numbers\n"); printf("\nEnter numbers (After Entering all the values Enter -100):"); for(i=1;;i++) { scanf("%f",&a[i]); if(a[i]==-100) break; } sum=0; for(i=1;;i++) { if(a[i]==-100) break; sum=sum+a[i]; n=i; } printf(" Sum = %f \n n = %d",sum,n); mean=sum/n; ssd=0;

//ssd=sum of square of deviation// for(i=1;;i++) { if(a[i]==-100) break; ssd=ssd+((a[i]-mean)*(a[i]-mean)); } var=ssd/n; sd=sqrt(var); printf("\n Mean = %0.3f \n Standard Deviation = %0.3f ",mean,sd); getch(); }