My code is not working pls help

Hello i need help.
I was working on my guess a number game and my two last lines of code is not working can someone tell me why all my code is in the C# I will be very grateful for help
Ther is the code:
using System;

namespace ZgadywanieLiczb
{
class Program

{
    static void Main(string[] args)
    {
        Random randome = new Random();
        int x = randome.Next(1, 101);
        Console.WriteLine("Zgadnij liczbe jaką wylosowałem!");
        int zga2 = Convert.ToInt32(Console.ReadLine());
        int zga = zga2;


        while (zga != x)
        {
            if (zga2 - 50 > x || zga2 + 50 < x)
            {
                Console.WriteLine("Zero absolutne!");
                Console.WriteLine("Zgaduj dalej!");
                zga2 = Convert.ToInt32(Console.ReadLine());
                zga = zga2;
            }

            else if (zga2 - 20 > x || zga2 + 20 < x)
            {
                Console.WriteLine("Zimno!");
                Console.WriteLine("Zgaduj dalej!");
                zga2 = Convert.ToInt32(Console.ReadLine());
                zga = zga2;
            }

            else if (zga2 - 10 > x || zga2 + 10 < x)
            {
                Console.WriteLine("Cieplej!");
                Console.WriteLine("Zgaduj dalej!");
                zga2 = Convert.ToInt32(Console.ReadLine());
                zga = zga2;
            }

            else if (zga2 - 5 > x || zga2 + 5 < x)
            {
                Console.WriteLine("Gorąco!");
                Console.WriteLine("Zgaduj dalej!");
                zga2 = Convert.ToInt32(Console.ReadLine());
                zga = zga2;
            }

            else if (zga2 - 3 > x || zga2 + 3 < x)
            {
                Console.WriteLine("Wulkan!");
                Console.WriteLine("Zgaduj dalej!");
                zga2 = Convert.ToInt32(Console.ReadLine());
                zga = zga2;
            }

            else if (zga2 - 1 > x || zga2 + 1 < x)
            {
                Console.WriteLine("Słonce!");
                Console.WriteLine("Zgaduj dalej!");
                zga2 = Convert.ToInt32(Console.ReadLine());
                zga = zga2;
            }
            
        }
        Console.WriteLine("Zgadłeś moją liczbe!");
        Console.WriteLine("Moją liczbą było" + x);

    }

}

}

You added a variable for the last console.writeline but you forgot to add the $ sign to tell the console to expect a variable in the output.

1 Like