RAD Studio
ContentsIndex
PreviousUpNext
random

Header File 

stdlib.h  

Category 

Math Routines 

Prototype 

int random(int num); 

Description 

Random number generator. 

random returns a random number between 0 and (num-1). random(num) is a macro defined in stdlib.h. Both num and the random number returned are integers. 

Return Value 

random returns a number between 0 and (num-1). 

Example  

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
/* prints a random number in the range 0 to 99 */
int main(void)
 {
    randomize();
    printf("Random number in the 0-99 range: %d\n", random (100));
    return 0;
}

Portability

POSIX 
Win32 
ANSI C 
ANSI C++ 
 
 
 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!