dimanche 23 avril 2017

Floating point exception (core dumped).In creator random numbers

I am trying to create a program to give random numbers in the range between 0 and 0,3. And with give by user seed. My code is:

#include <stdio.h>
#include <stdlib.h>
int getrand(int min,int max);
int main()
{
 unsigned seed;

 int p=0, i=0;
 float min,max;
 printf("Input a random number seed: ");
 scanf("%u",&seed);
 srand(seed);

  for(i=0;i<getrand(0,0.3); i++) p=getrand(min,max);

printf("Random value : %d \n",p);


 return(0);
}
int getrand(int min,int max){
    return(rand()%(max-min)+min);
}

and 

When i run it it give me this error: Floating point exception (core dumped) I can found the error.




Aucun commentaire:

Enregistrer un commentaire