I've created a simple guessing game program. My problem is I'm not sure how to loop the program back to the beginning of the program once the user has guessed a wrong number. I want the program to continue asking the user for a number until he gets it right. Can someone help me?
#include <stdio.h>
int main (void) {
int value = 58;
int guess;
printf("Please enter a value: ");
scanf("%i", &guess);
if (guess == value) {
printf("Congratulations, you guessed the right value");
}
else if (guess > value) {
printf("That value is too high. Please guess again: ");
scanf("%i", &guess);
}
else if (guess < value) {
printf("That value is too low. Please guess again: ");
scanf("%i", &guess);
}
return 0;
}