fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include "time.h"
  4.  
  5. int Droll()
  6. {
  7. int outcome;
  8. int l_limit = 1; // floor or lower limit of a die
  9. int h_limit = 6; //ceiling or higher limit of a die
  10.  
  11. outcome = rand() % (h_limit - l_limit + 1) + l_limit;
  12.  
  13. return outcome;
  14. }
  15.  
  16. int main()
  17. {
  18. srand(time(0));
  19. for(int i=0;i<1;i++)
  20. {
  21. std::cout << Droll() << " ";
  22. }
  23. }
Success #stdin #stdout 0.01s 5476KB
stdin
Standard input is empty
stdout
5