After than ı find the answer.I get 2 times the question that"Excellent!..like to play again(y or no);.Even if ı write y or n.Problem not change to depends the answer.(By the way ı am sorry for my bad english).
I have tried to change position of that statment(if(answer..) to the first line of the while or end line or smth like things.Also ı have tried put break somewhere(ı think the problem is not about to this but ı tried).
int main() {
srand(time(NULL));
int guess,number;
char answer;
number=1+(rand()%1000);
printf("I have a number between 1 and 1000\n");
printf("Could you guess my number?\n");
printf("Please type your guess\n");
while(1) {
scanf("%d",&guess);
if(guess==number) {
printf("Excellent!You guessed the number!Would you like to play again(y or n)");
scanf("%c",&answer);
if(answer=='y') {
number=1+(rand()%1000);
printf("I have a number between 1 and 1000 \n");
printf("Could you guess my number? \n");
printf("Please type your guess \n");
}
else if(answer=='n') {
return 1;
}
}
else if(guess>number){
printf("Too high.Try again.\n");
}
else if(guess<number){
printf("Too low.Try again.\n");
}
}
}