Last active
September 26, 2017 11:23
-
-
Save Gimanua/33d2736274c94f3cd3383d81df3631e7 to your computer and use it in GitHub Desktop.
C# Gissningsspel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random rnd = new Random(); | |
int numb = rnd.Next(1, 101); | |
int guess, guesses = 0; | |
Console.WriteLine("Gissa på ett tal mellan 1-100"); | |
do | |
{ | |
guess = int.Parse(Console.ReadLine()); | |
guesses++; | |
if (guess == numb) | |
Console.WriteLine("Grattis, du gissade rätt!"); | |
else if (guess < numb) | |
Console.WriteLine("Du gissade för lågt, försök igen."); | |
else | |
Console.WriteLine("Du gissade för högt, försök igen."); | |
} while (guess != numb); | |
Console.WriteLine("Du gissade: " + guesses + " gånger."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment