C# - Programming Language
This course covers the basics of programming in C#. Work your way through the videos/articles and I'll teach you everything you need to know to start your programming journey!

Building A Guessing Game

Lesson 19
Author : 🦒
Last Updated : November, 2017


Code

Copystring secretWord = "giraffe";
string guess = "";
int guessCount = 0;
int guessLimit = 3;
bool outOfGuesses = false;

while(!guess == secretWord && !outOfGuesses){
     if(guessCount < guessLimit){
          Console.Write("Enter a guess: ");
          guess = Console.ReadLine();
          guessCount++;
     } else {
          outOfGuesses = true;
     }
}

if(outOfGuesses){
     Console.WriteLine("You Lose!");
} else {
     Console.WriteLine("You Win!");
}