Hello! I'm trying to create a simple program where one user enters a number, then another user shall guess the right number. The problem i'm having is that i want the second user to be able to guess a number again if it turned out to be the wrong number. I guess i have to create some sort of loop but i really don't know how. Greatly appreciate any help.
This is my code so far:
Code:
#include <stdio.h>
int main(int argc, const char * argv[])
{
int number, guess;
printf("Enter a number from 1 to 10: ");
scanf("%d", &number);
printf("Guess a number from 1 to 10:");
scanf("%d", &guess);
if (guess < number)
{
printf("The number is bigger!");
}
if (guess > number)
{
printf("The number is smaller! ");
}
else if (guess == number)
{
printf("Right number! The number was: %d" , number);
}
return 0;
}