New to programming. Can anyone tell me why this number guessing game isn’t working properly? :)

Random random = new Random();

int number = random.Next(1, 100);

Console.WriteLine("Im thinking of a number between 1 and 100. Can you guess what it is?");

int response = Convert.ToInt32(Console.Read());

 while (response != number) { if (response < number) { Console.WriteLine("higher, guess again :)"); response = Convert.ToInt32(Console.Read()); } else if (response > number) { Console.WriteLine("lower, guess again :)"); response = Convert.ToInt32(Console.Read()); } } Console.WriteLine("Yes!! The correct number is ", number); Console.ReadLine(); 

by firefighters83 via /r/csharp

Leave a Reply