Section courante

A propos

Section administrative du site

RAND

Aléatoire
Turbo C stdlib.h

Syntaxe

int rand(void);

Description

Cette fonction retourne un nombre pseudo-aléatoire entier.

Exemple

Voici un exemple permettant d'afficher des nombres aléatoires :

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.      
  4. int main() {
  5.  printf("Aleatoire entier = %i\n",rand());
  6.  printf("Aleatoire entier (0 a 9) = %i\n",rand() % 10);
  7.  return 0;
  8. }

on obtiendra le résultat semblable suivant :

Aleatoire entier = 41
Aleatoire entier (0 a 9) = 7


Dernière mise à jour : Samedi, le 4 juillet 2015