Program: #include #include<stdio.h> #include<stdlib.h> #include<math.h> void main() { int run=0,i,n1=0,n2=0; float a[20]; char b[20]; float m, z0,sb,sb2,n=20.0; clrscr(); for(i=0;i<20;i++) { a[i]=(rand()%100*0.01); printf("\t %f",a[i]); } printf("\n"); printf("\n"); printf("\n"); printf("\n"); for(i=0;i<20;i++) { if(a[i]<0.459) { b[i]='-';
n2++; } else { b[i]='+'; n1++; } printf("\t%c",b[i]); } printf("\n"); printf("\n"); for(i=0;i<20;i++) { if(b[i]!=b[i+1]) { run++; }} printf("\nrun(b)=%d",run); printf("\n"); printf("\n No.OF+VE SIGN=%d",n1); printf("\n"); printf("\n No.OF-VE SIGN=%d",n2); printf("\n"); m=((2*n1*n2)/n)+(0.5); printf("\nm=%f",m); printf("\n"); sb2=((2*n1*n2)*((2*n1*n2)-n))/((n*n)*(n-1));
printf("\n variance=%f",sb2); printf("\n"); sb=sqrt(sb2); printf("\n"); z0=(run-m)/sb; printf("\nz0=%f",z0); printf("\n"); printf("\n"); if(z0<1.96) { printf("\n HYPOTHENSIS IS ACCEPTED"); } else { printf("\n HYPOTHENSIS IS NOT ACCEPTED"); } getch(); }
Output: