Many algorithm correctness and performance tests, games and others require random number generation. Here is a way to generate a random number between two limits min and max.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int randomnum;
int min=1; /* lower limit */
int max=7; /*upper limit */
time_t seconds;
time(&seconds);
srand((unsigned int) seconds); /*seed for rand() */
randomnum = rand() % (max-min+1) + min; /*generate random number [...]