Search
 
SCRIPT & CODE EXAMPLE
 

C

c get random float

//random float between 0 and a
float x = (float)rand()/(float)(RAND_MAX/a);
Comment

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;
}
Comment

PREVIOUS NEXT
Code Example
C :: Calculator_C 
C :: arduino digital input pins 
C :: Successeur récurssive 
C :: c format specifiers 
C :: find the largest number among five numbers in c language 
C :: armstrong number using function in c 
C :: c for schleife 
C :: c language append line to file 
C :: count number of vowels in a string in c 
C :: reverse list in C 
C :: how to print the first character of a string in c 
C :: ROUNDING decimal number in C 
C :: c check if char is an operator 
C :: how to make a linked list in c 
C :: multiplication table in c using array 
C :: limit axis in one direction plt 
C :: c float 
C :: how to open a file with open in c 
C :: c read file 
C :: c check first character of string 
C :: arrays in c 
C :: enregistrement en c 
C :: how to get file size in c 
C :: variable swap in c 
C :: pandoc set margins pdf 
C :: how to free memory in c 
C :: Create the static library libmy.a containing all the functions listed below: 
C :: Find the how many bits is turned on in a numebr 
C :: pointer in c 
C :: insse suprafata arabila pe ani 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =