c get random float
//random float between 0 and a
float x = (float)rand()/(float)(RAND_MAX/a);
c get random float
//random float between 0 and a
float x = (float)rand()/(float)(RAND_MAX/a);
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\n", ((float)rand()/(float)(RAND_MAX)) * max);
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us