hey guys I have a question on this guessing game. I want to make this game to repeat. when the guess is correct, i wanted the user to input 'y' or 'n' and if yes it should repeat. How can i do that? Do I have to put the whole program in to another while loop?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int g;
int x;
char a;
srand (time(NULL));
g = rand() % 1000+1;
printf("I have a number between 1 and 1000\nCan you guess my number\?\nPlease type your first guess\n");
scanf("%d", &x);
while (g!=x){
if (g<x)
printf("Too high. Try again\n");
else if (g>x) printf("your guess is less\n");
scanf("%d", &x);
}
printf("Excellent!you guess the number\nWould you like to play again (y or n)?\n");
return 0;
}