Skip to content

Instantly share code, notes, and snippets.

@megabites2013
Created March 20, 2021 10:15
Show Gist options
  • Save megabites2013/924e109ee134cc2fff2da57d442258d0 to your computer and use it in GitHub Desktop.
Save megabites2013/924e109ee134cc2fff2da57d442258d0 to your computer and use it in GitHub Desktop.
using System;
class MainClass
{
static void Main (string[] args)
{
string secretWord = "Nicholas";
string guess = "";
int guesscount = 0;
while(guess != secretWord){
Console.WriteLine("enter guess: ");
guess = Console.ReadLine();
guesscount++;
Console.WriteLine(guesscount);
if(guesscount >= 5){
Console.WriteLine("you failed, the answer was: " + secretWord);
break;
} else if(guess == secretWord){
Console.WriteLine("You win!");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment