Advertisement
campos20

Untitled

May 10th, 2020
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. // Numeros aleatorios
  6. // Autor: Alexandre Campos
  7.  
  8. int main()
  9. {
  10.     // Declaracao
  11.     int aleatorio;
  12.     int n = 15; // Quantidade de numeros a serem gerados
  13.  
  14.     // Informa uma fonte para os numeros aleatorios
  15.     // time(NULL) informa os segundos desde 01/01/1970 ate agora
  16.     srand(time(NULL));
  17.  
  18.     // Repetir n vezes
  19.     for (int i=0; i<n; i++)
  20.     {
  21.         // Gera um numero aleatorio, randomico (random)
  22.         aleatorio = rand();
  23.  
  24.         // Exibicao em tela
  25.         printf("Numero aleatorio e %d\n", aleatorio);
  26.     }
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement