using System.Collections.Generic;
static string GeneratePassword(string name,int age)
Console.WriteLine("Welcome your password is your name and age together");
string password=name+Convert.ToString(age);
int choice,i,f=0,wordCount;
string SecretString,GuessString;
Queue<string> secretword = new Queue<string>();
string[] a= new string[secretword.Count];
Console.WriteLine("Welcome to CowBull");
Console.WriteLine("1)Give Word");
Console.WriteLine("2)Guess word");
Console.WriteLine("3)Exit");
choice=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the 4 letter secret word");
SecretString=Console.ReadLine();
if(SecretString.Length!=4)
Console.WriteLine("Enter the 4 letter string and try again!!");
}while(SecretString.Length!=4);
secretword.Enqueue(SecretString);
Console.WriteLine("The Word is added to the queue");
Console.WriteLine("Total words present in the queue are:"+secretword.Count);
Console.WriteLine("Enter the choice of word which you want to guess:");
wordCount=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter your guessed word");
GuessString=Console.ReadLine();
if(GuessString.Length!=4)
Console.WriteLine("Enter a 4 letter word and try guessing");
}while(GuessString.Length!=4);
foreach(var String in secretword)
Console.WriteLine("Cow=4,Bull=0");
Console.WriteLine("You Won");
Console.WriteLine("Cow=3,Bull=1");
Console.WriteLine("Cow=2,Bull=2");
Console.WriteLine("Cow=1,Bull=3");
Console.WriteLine("Cow=0,Bull=4");
Console.WriteLine("Enter a valid number and try again");
public static void Main()
int choice,age,i=0,j,enteredUserId,wish;
int[] returnedIdValue=new int[10];
int[] GeneratedId=new int[10];
string name,enteredPassword;
string[] GeneratedPassword=new string[10];
Console.WriteLine("Welcome to the game");
Console.WriteLine("1)Register");
Console.WriteLine("2)Login");
choice=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter your name");
Console.WriteLine("Enter your age");
age=Convert.ToInt32(Console.ReadLine());
returnedIdValue[i]=GenerateId();
GeneratedId[i]=returnedIdValue[i]+i;
Console.WriteLine("Your user id is:"+GeneratedId[i]);
GeneratedPassword[i]=GeneratePassword(name,age);
Console.WriteLine("Enter your user id");
enteredUserId=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter your password");
enteredPassword=Console.ReadLine();
if((enteredUserId==GeneratedId[j])&&(enteredPassword==GeneratedPassword[j]))
Console.WriteLine("Your Username or Password is incorrect");
Console.WriteLine("Enter a valid number");
Console.WriteLine("Do you wish to continue?\\1)Yes\\n2)No");
wish=Convert.ToInt32(Console.ReadLine());