Guessing game
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sololearn
{
class Program
{
static void Main(string[] args)
{
Random randomGenerator = new Random();
int randomNumber = randomGenerator.Next(1,11);
Console.WriteLine("Enter Number from 1 to 10");
string output;
int userNumber = int.Parse(Console.ReadLine());
//Console.WriteLine("You entered {0}",userNumber);
//Console.WriteLine("Computer generated number {0}",randomNumber);
if(userNumber == randomNumber)
{
output = "Your guess is correct";
}
else if(userNumber < randomNumber)
{
output = "Your guess is less";
}
else if(userNumber > randomNumber && userNumber <=10)
{
output = "Your guess is higer";
}
else
{
output ="Invalid Range";
}
Console.WriteLine(output);
}
}
}
Comments
Post a Comment