Problem in generating random number. [Error] 'rand' was not declared in this scope

#include <stdio.h>
int main()
{
int iRandomNum = 0;
int iResponse = 0;
iRandomNum = (rand() % 10) + 1;
printf("\nGuess a number between 1 and 10: “);
scanf(”%d", &iResponse);
if (iResponse == iRandomNum)
printf("\nYou guessed right\n");
else {
printf("\nSorry, you guessed wrong\n");
printf(“The correct guess was %d\n”, iRandomNum);
}
}

your code is working fine on codeblocks. can you please tell which IDE you are using?

include cstdlib .I think it should work.