Finally solved the problem. Thanks laserlight, you were right. And thank you to everyone else... Now I'm not even sure if the number generator was malfunctioning before, but it works now.
Code:
#include<stdio.h>
#include<time.h>
#include<math.h>
main(){
int hundreds, tens, ones, guess, guessnum, guesshundreds, guesstens, guessones, randomhundreds, randomtens, randomones;
/*number generator*/
srand(time(NULL));
int N = 999;
int random = 100 + rand() % N;
/*guess an 3-digit integer > allow for only 10 guesses */
for(guessnum=1; guessnum<=10; guessnum++){
printf("Please make a guess: ");
scanf("%d", &guess);
guesshundreds=guess/100;
guesstens=(guess/10)%10;
guessones= guess%10;
randomhundreds=random/100;
randomtens=(random/10)%10;
randomones= random%10;
/*if the guess equals the random generated number, game is over*/
if (guess==random){
printf("You guessed right! It is %d\n", random);}
/*if you guess a correct number but not in the correct "place", you made a match */
else if ((guess)== randomhundreds || guess==randomtens || guess==randomones)
printf("You made a match!\n");
/*if you guess the correct number in the hundreds place, you've made a hit */
else if (guesshundreds== randomhundreds)
printf("%d is a hit!\n", guesshundreds);
/*if you guess the correct number in the tens place, you've made a hit */
else if (guesstens== randomtens)
printf("%d is a hit!\n", guesstens);
/*if you guess the correct number in the ones place, you've made a hit */
else if (guessones== randomones)
printf("%d is a hit!\n", guessones);
}
return(0);
}