Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active May 16, 2023 16:06
Show Gist options
  • Save Strelok78/34c63f7abbe56172684585ef945ee4a8 to your computer and use it in GitHub Desktop.
Save Strelok78/34c63f7abbe56172684585ef945ee4a8 to your computer and use it in GitHub Desktop.
The user enters the password, then user has 3 chances to enter correct password. If the password fits, it outputs a secret message, else program ends.
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
string enter;
string password = "iJunior";
int tries = 3;
for (int i = 0; i < tries; i++)
{
Console.WriteLine("Enter password:");
enter = Console.ReadLine();
if (enter == password)
{
Console.WriteLine("Correct password!");
Console.WriteLine("LEEROY JENKIIIIINS!");
break;
}
else
{
Console.WriteLine("Worng password, try again!\n");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment