0

I am Building guessing game C# make a “youre close” answer ,closing guessing

 

I’m making a guessing game (guess between 1-1000). and I need answer that I’m wrong but was close. I have the code (int diff = Math.Abs(guess - num); if (diff <= 3) but I don’t know where to putt it.

I have made to that I have a number that is right so that it is easier to to see if I have done my code right (and will change it after)

 Console.WriteLine("gissa talet\nDu ska nu gissa ett tal mellan 1 ocn 100, sÄ 
 varsÄgod..\nskriv in ett tal");
 int guess = Convert.ToInt32(str);
 //gonna make it random between 1-100
 int num = (50);
 {
 //when im right
 if (guess == num)
 {
    Console.WriteLine("rÀtt");
 }
 //when itÂŽs to small guess
 else if (guess < num)
 Console.WriteLine("för lite");

 // to large guess
 if (guess > num)
    Console.WriteLine("för stort");

 // when i make it random nr and i guess over 100
 if (guess > 50)
    Console.WriteLine("gissa mellan 1-100");

 Console.ReadLine();
 }
Nilesh Raut Changed status to publish July 20, 2023