You need to use a seed to get different values. Use srand() function before rand() function so that the random function can use different seed values. If you do not explicitly use srand() function, rand() function uses srand(1). You can use time(0) [current time] to generate the seed value. Check the following example.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
srand(time(0)); //set seed value
int i = rand();
printf ("Random number is %d\n",i);
return 0;
}