Guest User

Untitled

a guest
Jun 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. int diceroll_1;
  2. diceroll_1=(rand()%3)+1;
  3. printf("%dn",diceroll_1);
  4.  
  5. #include <time.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int main(void)
  10. {
  11. srand(time(NULL)); // only once
  12.  
  13. // roll the dice
  14. int diceroll_1;
  15. diceroll_1=(rand()%3)+1;
  16. printf("%dn",diceroll_1);
  17.  
  18. return 0;
  19. }
  20.  
  21. Georgioss-MacBook-Pro:~ gsamaras$ gcc -Wall main.c
  22. Georgioss-MacBook-Pro:~ gsamaras$ ./a.out
  23. 3
  24. Georgioss-MacBook-Pro:~ gsamaras$ ./a.out
  25. 1
Add Comment
Please, Sign In to add comment