Posted By

cdnicoll on 01/25/11


Tagged

number random


Versions (?)

random number


 / Published in: C
 

  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h> // rand srand function
  5. #include <time.h> // time
  6. int main()
  7. {
  8. int randNumber;
  9.  
  10. // generate random seed
  11. srand ( (unsigned)time(0) );
  12.  
  13. // random number betweem 1 and 10
  14. randNumber = 1+rand()%10;
  15.  
  16. printf("%d ",randNumber);
  17.  
  18. return 0;
  19. }

Report this snippet  

You need to login to post a comment.