I can't see why this wouldn't work. Either I'm completely missing something or this book is missing something.
Code:
#include <stdio.h>
#include <windows.h>
main()
{
int iRandom = 0;
int iResponse = 0;
srand(time());
iRandom = (rand() % 6) + 1;
printf("\nPlease enter a number netween 1 and 6: ");
scanf("%d", &iResponse);
if (iResponse == iRandom)
printf("\nCongratulations, you guessed correct!\n");
else {
printf("\nUnlucky, good luck next time!\n");
printf("\nThe correct number was %d!\n", iRandom);
}
Sleep(5000);
}
Thanks.