[ create a new paste ] login | about

Link: http://codepad.org/9pRLCgt2    [ raw code | output | fork ]

C, pasted on Mar 25:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>     
#include <stdlib.h>  /* srand, rand */
#include <time.h>    

int main (){
 int i=0;
 srand (time(NULL));
 printf("Five rand numbers: \n");
 for(i = 1; i <= 5; i++){
   printf("\n %d", rand());
 }
 
 printf("\n Five rand numbers between 2 to 5: \n");
 for(i = 1; i <= 5; i++){
   printf("\n %d", (2 + rand()%4));
 }

 return 1;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Five rand numbers: 

 1052428643
 1098776953
 661867706
 429186290
 108642022
 Five rand numbers between 2 to 5: 

 4
 4
 4
 5
 3


Create a new paste based on this one


Comments: