C# Program of Secret Number guess Game

C# Program of Secret Number guess Game

C Sharp is usually known as C#. This Language is basically the Programming Language which is mainly used for object orientation. this language was developed by Microsoft. i personally feel that many people face problem while writing such codes for particular program. So, that is the reason i decided to create C Sharp problem resolving  post for that type of people. Here is a main program where approximately every beginner stuck.

Question:


Make a game in C#, in which give 5 tries to the user to
guess the value of the number.

Code:


{
            Console.WriteLine("\t\t\tWelcome To ETR  Game");
            Console.WriteLine("\n\nDo you Wanna play this game :");
            Console.WriteLine("\n\t\tif Yes write 1 And if No write 0");
            int Will = Convert.ToInt32(Console.ReadLine());
            if(Will == 1)
            {
                Console.WriteLine("Enter you Age: ");
                int age = Convert.ToInt32(Console.ReadLine());
                if(age<=5)
                {
                    Console.WriteLine("Sorry\nyou are too young to play this Game\nBetter Luck next time");
                }
                else
                {
                    for (int i = 4; i >= 0; i--)
                    {
                        Console.WriteLine("Guess The Secret Number:");
                        int num0 = Convert.ToInt32(Console.ReadLine());
                        if (num0 != 7)
                        {
                            Console.WriteLine("You have " + i + " chance(s) Left.\n");
                        }
                        else
                        {
                            Console.WriteLine("You have successfully Guess the Secret number.");
                            break;
                        }
                    }
                 }
            }
            else
            {
                Console.WriteLine("Ok, You are not willing to play this game\nThank You");
            }
            Console.WriteLine("Thanks for Being with us. Thank you..!\n");
        }

Output: 

C# Program of Secret Number guess Game
Output of C# Program of Secret Number guess Game

Faisal Mukhtar

Assalam u Alaikum. I am web Developer, Web Application Developer, Web Designer, Free Lancer, Intro and outro maker, Logo Designer. If you like my work, so kindly give your feedbacks and intouch with me through my Social Links. Thank You