Advertisement
Abelsor

Numero Aleatorio

Mar 20th, 2023
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1.  
  2.                 //  Generar Numeros Aleatorios
  3.                
  4. #include<iostream>
  5. #include<ctime>
  6. // #include<time.h>  otra forma
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     int limite_inferior = 50;
  13.     int limite_superior = 100;
  14.    
  15.     srand(time(NULL));
  16.    
  17.     int numero_aleatorio = limite_inferior + rand()%(limite_superior-limite_inferior + 1);
  18.    
  19.    
  20.     cout<<numero_aleatorio<<endl;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement