Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

counting the frequency of randomly generated real number

  Asked By: Sanjay    Date: Oct 30    Category: C Programming    Views: 1294
  

I am trying to write the code to find the frequency of real random number generated.It does not give any error but on compilation it shows blank. Here is the code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
int i,j;
float randomNumber;
float array_1[101];
float *array_2[101];
//float array_3[101];
int count[101]={0};

srand ((unsigned) time(NULL));
for(i =0; i<100; i++)
{
randomNumber = (rand() %100-1) ;
printf("Index[%d] = %f\n",i,randomNumber);
array_1[i]= randomNumber++;
array_2[i]=NULL;
//array_2[i]= &array_1[i];


for(j=0;j<100;j++)
{
//for(k=1;k<100;k++)
//{

if(array_1[j]==*array_2[j])
{
//array_3[j]=*array_2[j];
count[j]=count[j]+1;
}
else
{
count [j]=0;
}

}
}
for (j=1; j<100; j++)
{
*array_2[j]= (float)(j);
j++;
}
for(j=1; j<100; j++)
{
printf("The number [%f] has been randomly generated[%d]times \n",array_2[j],count[j]);
}
return 0;
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on counting the frequency of randomly generated real number Or get search suggestion and latest updates.




Tagged: