i am trying to find the frequency of real random number generated. It shows no error but do not give the desire result. Here is the code #include <stdio.h> #include <stdlib.h> #include <time.h>
int main(void) {
int i,n=0; float randomNumber; float array_1[101] ;
srand ((unsigned) time(NULL)); for(i = 1; i<100; i++) { randomNumber = (rand() %100) ; printf("Index[%d] = %f\n",i,randomNumber); array_1[i]=randomNumber++; for (i=1;array_1[i]<100;i++) { if(randomNumber==array_1[i]) ++n; } for (i=0;i<100;i++) { printf("The number [%f] has been randomly generated[%d]times \n",array_1[i],n); return 0; } } } |