Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

random float number in C

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

int main()
{
    srand(time(NULL));

    float max = 1.5;
  	//algorithm for creating a random number 
  				//(float cast) (float cast)	(RAND_MAX) is a costant included in the lib time.h
    printf("%f
", ((float)rand()/(float)(RAND_MAX)) * max);
    return 0;
}
Source by www.itsmycodelmao.it #
 
PREVIOUS NEXT
Tagged: #random #float #number #C
ADD COMMENT
Topic
Name
5+5 =