Guessing game 2
using System;
namespace GuessingGame2
{
class Program
{
static void Main()
{
Random randomGenerator = new Random();
int randomNumber = randomGenerator.Next(1, 51);
//Console.WriteLine(randomNumber);
int userNum;
int counter = 0;
do
{
Console.WriteLine("Enter a Number 1 to 50");
userNum = int.Parse(Console.ReadLine());
if (userNum < randomNumber)
Console.WriteLine("Your num is less");
else if (userNum > randomNumber)
Console.WriteLine("Your num is high");
else
Console.WriteLine("Your correct");
counter++;
} while (userNum != randomNumber);
Console.WriteLine("Turns taken : {0}", counter);
}
}
}
Comments
Post a Comment