#include <stdio.h>
#include <time.h>
main(void)
{
srand(time(NULL));
int a=rand()%5;
printf("%d",a);
}

こんな感じですか?