I am fairly new to programming. I've heard that using GOTO statements is not good. so i would appreciate any recommendations on what to use instead.Thanks for helping.
Start:
Random numGen = new Random();
int num = numGen.Next(1, 101);
Console.WriteLine("Guess the number between 1 and 100");
Console.Write("Your answer: ");
fail:
int answer = Convert.ToInt32(Console.ReadLine());
if (answer == num)
{
Console.WriteLine("Congratulations,the number was " + num);
Console.WriteLine();
goto Start;
}
else if (answer > num)
{
Console.WriteLine("Lower");
goto fail;
}
else
{
Console.WriteLine("Higher");
goto fail;
}