Menu
- The C Standard Library
- C Standard Library Resources
- C Programming Resources
- Selected Reading
Mar 24, 2012 Curso de C // Cap. 13 // Sacar numeros aleatorios y el operador '%'. En este tutorial vemos como obtener numeros completamente aleatorios con las funciones rand; y srand; y ademas. Para quienes necesiten saber como realizar o utilizar los numeros aleatorios en C o C aqui les dejo un manual que hice hace un tiempo, para quienes no sepan, con esta funcion ustedes podran ahorrase el testeo de sus aplicaciones o el llenado de variables, vectores, matrices, etc, simplemente llamando a esta funcion y se almacenaran los valores que puedan predefinir, y si. RANDMAX is a constant whose default value may vary between implementations but it is granted to be at least 32767. Declaration Following is the declaration for rand function. In C, the generation algorithm used by rand is guaranteed to only be advanced by calls to this function. In C, this constraint is relaxed, and a library implementation is allowed to advance the generator on other circumstances (such as calls to elements of random).
Description
The C library function void srand(unsigned int seed) seeds the random number generator used by the function rand.
Declaration
Following is the declaration for srand() function.
Parameters
![Gratis Gratis](/uploads/1/2/6/8/126884282/989242402.jpg)
- seed − This is an integer value to be used as seed by the pseudo-random number generator algorithm.
Return Value
Random Function Dev C++
This function does not return any value.
Funcion Rand En Dev C Para
Example
Como Usar La Funcion Rand En Dev C++
The following example shows the usage of srand() function.
Let us compile and run the above program that will produce the following result −
stdlib_h.htm