Sayı tahmin oyunu — C# Console
Sayı tahmin oyunu — C# Console
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;//www.gorselprogramlama.com
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
int hak = 3,girilen,rsayi;
Random r = new Random();
rsayi=r.Next(1,30);
while (hak >0)
{
Console.Write("Sayı giriniz (1-30)>>>");//www.gorselprogramlama.com
girilen = Convert.ToInt32(Console.ReadLine());
if (girilen != rsayi)
{
hak--;//www.gorselprogramlama.com
Console.WriteLine("Kalan tahmin hakkınız>> "+hak);
if (girilen > rsayi) Console.WriteLine("Aşağı");
else Console.WriteLine("Yukarı");
}//www.gorselprogramlama.com
else Console.WriteLine("Tebrikler , bildiniz...");
}
if (hak ==0) Console.WriteLine("Hakkınız tamamlandı.Sayı bilemediniz. Rastgele üretilen sayı="+rsayi);
Console.ReadKey();//www.gorselprogramlama.com
}
}
}



