#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { srand(time(NULL)); int i; for(i = 0; i<5; i++) printf("%d ", rand()%10); }
returns:
3 7 0 9 8
NOTE: srand() sets the seed which is used by rand() to generate random numbers.