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 :: how to combine strings in c 
C :: round function in c 
C :: to find greatest of 4 numbers in c 
C :: how to open a website in c 
C :: Graphics in C Draw Circle 
C :: xor swap 
C :: char array to int c 
C :: how make a character in c scanf 
C :: c if 
C :: directory folders structure show windows 10 command prompt 
C :: c memset 
C :: how to delete virtual hard disk virtualbox 
C :: memcpy c 
C :: malloc c include 
C :: check if string is the same c 
C :: convert c program to assembly language online 
C :: prime factorization in c 
C :: solana-test-validator log 
C :: gcd and lcd in c 
C :: int data types in c 
C :: how to return array of char in c 
C :: absolute value of intel intrinsic 
C :: c str add int 
C :: Create the static library libmy.a containing all the functions listed below: 
C :: integer in c 
C :: declaration of string in c 
C :: ubuntu ocaml install 
C :: Number 10 
C :: c hello word 
C :: c %d 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =