[ create a new paste ] login | about

Link: http://codepad.org/DrR4EdUZ    [ raw code | output | fork ]

C, pasted on Oct 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main (int argc, char *argv[])
{
    /*declare pseudo-random number */
    float random;
    srand(time(NULL));

    random = (float) rand() / (float) RAND_MAX;
    printf("The random number is %f\n", random);

    return 0;
}


Output:
1
The random number is 0.370939


Create a new paste based on this one


Comments: