Logo 
Search:

C Programming Article

Submit Article
Comments on Program for frequency counting
Category: C Programming (Beginners)    Author: Louis Evans

Program for frequency counting.


Sanjay Dutta
Sanjay Dutta from IndiaOct 22
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;
}
}
}


Please enter your Comment
  • Comment should be atleast 15 Characters.
  • Please put code inside [Code] your code [/Code].